代码如下: Public Function LoadGLTextures() As Boolean 'Load up desired bitmaps and convert them into textures 'that can be used by OpenGL
Dim sFile As String Dim bmFile As BITMAPFILEHEADER Dim bmInfo As BITMAPINFOHEADER Dim bmRGB() As RGBQUAD Dim iFile As Integer Dim lImageSize As Long Dim iPixelSize As Integer Dim baImageData() As Byte
On Error GoTo ERR_H
'Set the filename sFile = App.Path & "\" & TEXTURE_FILE
iFile = FreeFile
Open sFile For Binary As iFile
'Read in the headers Get #iFile, , bmFile Get #iFile, , bmInfo
'Determine how many colors are used If (bmInfo.biBitCount < 24) Then 'Less than 24 bits per pixel are used, so read in the color table ReDim bmRGB(bmInfo.biClrUsed)
Get #iFile, , bmRGB End If
'Determine how big the image is iPixelSize = bmInfo.biBitCount / 8