本人写了一个从文件中读取BMP格式图片的小程序,所选图片均为24位无压缩格式,代码如下。但是在使用中,发现有些BMP图片可以正确读取,有些就会错位,不知道是什么原因,请高手指点一下,谢谢。Private Type BITMAPFILEHEADER
   bfType As Integer
   bfSize As Long
   bfReserved1 As Integer
   bfReserved2 As Integer
   bfOffBits As Long
End TypePrivate Type BITMAPINFOHEADER
   biSize As Long
   biWidth As Long
   biHeight As Long
   biPlanes As Integer
   biBitCount As Integer
   biCompression As Long
   biSizeImage As Long
   biXPelsPerMeter As Long
   biYPelsPerMeter As Long
   biClrUsed As Long
   biClrImportant As Long
End TypePrivate Type ColorRGB
   B As Byte
   G As Byte
   R As Byte
End TypePrivate Sub Command1_Click()
   Dim strFileName As String
   Dim MyBitmapFileHeader As BITMAPFILEHEADER
   Dim MyBitmapInfoHeader As BITMAPINFOHEADER
   Dim clrBitmapRGB() As ColorRGB
   Dim x As Integer, y As Integer
   
   strFileName = "D:\ITEM\图像处理\photo\LENA_RGB.BMP"
   
   Open strFileName For Binary As #1
   Get #1, , MyBitmapFileHeader
   Get #1, , MyBitmapInfoHeader
   Close #1
   
   ReDim clrBitmapRGB(MyBitmapInfoHeader.biWidth - 1, MyBitmapInfoHeader.biHeight - 1) As ColorRGB
   
   Open strFileName For Binary As #1
   Get #1, MyBitmapFileHeader.bfOffBits + 1, clrBitmapRGB()
   Close #1
   
   For x = 0 To MyBitmapInfoHeader.biWidth - 1
      For y = 0 To MyBitmapInfoHeader.biHeight - 1
         picShow.PSet (x * Screen.TwipsPerPixelX, y * Screen.TwipsPerPixelY), RGB(clrBitmapRGB(x, y).R, clrBitmapRGB(x, y).G, clrBitmapRGB(x, y).B)
      Next y
   Next x
End Sub