我知道DirectX7读入图片一般采用直接读取文件,哪位兄弟能告诉我如何读取资源文件中的图片?先谢谢了

解决方案 »

  1.   

    不会吧,没有用DirectX的吗?
      

  2.   

    vb中读取res中图片也是存成文件
    然后Set LoadPictureResource = LoadPicture(sFileName)有个例子,是vb中读取res中图片
    留下你的mail
      

  3.   

    1,假定你的资源文件如下: 
        102 GIF c:\about.gif 
        '用自定义函数SaveFileFromRes将资源文件中的gif文件另存为C:\temp.gif
        SaveFileFromRes(102, "GIF", "C:\temp.gif") 
        '下面就可以用directx直接读入C:\temp.gifSaveFileFromRes函数如下:
    Public Function SaveFileFromRes(vntResourceID As Variant, sType As String, sFileName As String) As Boolean
         '======================================================='
         '函数:SaveFileFromRes 
        '======================================================='
         目的: 从资源文件调入自定义资源,然后写入磁盘上的文件 '
         '返回值: 如果没有错误为True,否则为False '
         '注意: sType 必须同资源文件的定义相同(包括大小写)! '
         ' 假定sFilename是合法的,可写的 '
         '======================================================='
         Dim bytImage() As Byte ' Always store binary data in byte arrays!
         Dim iFileNum As Integer 'Free File Handle
         On Error GoTo SaveFileFromRes_Err
         SaveFileFromRes = True
         'Load Binary Data from Resource file
         bytImage = LoadResData(vntResourceID, sType)
         'Get Free File Handle
         iFileNum = FreeFile
         'Open the file and save the data
         Open sFileName For Binary As iFileNum
         Put #iFileNum, , bytImage
         Close iFileNum
         Exit Function
    SaveFileFromRes_Err:
         SaveFileFromRes = False: Exit Function
    End Function2.可用CreateSurfaceFromResource函数从包含位图资源的文件(例如.exe .dll)中建立页面CreateSurfaceFromResource并不是从资源文件(.res)中建立页面而是从包含位图资源的文件(例如.exe .dll)中建立页面
    函数的调用方法是这样的:
        CreateSurfaceFromResource( _ 
            file As String, _ 
            resName As String, _ 
            ddsd As DDSURFACEDESC2) As DirectDrawSurface7
    其中参数file问文件名,例如 res.dll ,参数resName为位图资源在资源文件中的名称
      

  4.   

    另外,注意directdraw中的CreateSurfaceFromFile函数好象只支持BMP文件,其它格式的文件,要先转换成bmp文件另外,如果资源文件中的图片为bmp的话,不用向上面那么麻烦(当然,上面的函数也可以)先用LoadResPicture函数将资源文件载入picturebox,再用savepicture函数将图片保存Function LoadResPicture(id, restype As Integer) As IPictureDisp
      

  5.   

    清高手们侃侃我的问题
    http://expert.csdn.net/Expert/topic/2582/2582719.xml?temp=.3797724