GetObject BmpHandle, Len(Bmp), Bmp
BmpSize = Bmp.bmWidthBytes * Bmp.bmHeight
With Bih
.biBitCount = Bmp.bmBitsPixel
.biClrImportant = 0
.biClrUsed = 0
.biCompression = BI_RGB
.biHeight = Bmp.bmHeight
.biPlanes = 1
.biSize = Len(Bih)
.biSizeImage = BmpSize
.biWidth = Bmp.bmWidth
.biXPelsPerMeter = 0
.biYPelsPerMeter = 0
End With
With Bif
.bfOffBits = 54
.bfReserved1 = .bfReserved2 = 0
.bfType = IsBitmapFile(&H4D42)
.bfSize = 54 + BmpSize
End With
BmpInfo.bmiHeader = Bih
ReDim BmpBinary(1 To Bmp.bmWidth * Bmp.bmHeight * 4) As Byte
GetDIBits DC, BmpHandle2, 0, BmpInfo.bmiHeader.biHeight, BmpBinary(1), BmpInfo, DIB_RGB_COLORS
Open "c:\temp.bmp" For Binary As #1
Put #1, , Bif
Put #1, , Bih
Put #1, , BmpBinary()
Close #1
以上是把一幅在内存中的位图保存到文件的代码,但当打开这幅位图之后,里面的画面是全黑的,请问给位高手我写错了哪里呢,
BmpSize = Bmp.bmWidthBytes * Bmp.bmHeight
With Bih
.biBitCount = Bmp.bmBitsPixel
.biClrImportant = 0
.biClrUsed = 0
.biCompression = BI_RGB
.biHeight = Bmp.bmHeight
.biPlanes = 1
.biSize = Len(Bih)
.biSizeImage = BmpSize
.biWidth = Bmp.bmWidth
.biXPelsPerMeter = 0
.biYPelsPerMeter = 0
End With
With Bif
.bfOffBits = 54
.bfReserved1 = .bfReserved2 = 0
.bfType = IsBitmapFile(&H4D42)
.bfSize = 54 + BmpSize
End With
BmpInfo.bmiHeader = Bih
ReDim BmpBinary(1 To Bmp.bmWidth * Bmp.bmHeight * 4) As Byte
GetDIBits DC, BmpHandle2, 0, BmpInfo.bmiHeader.biHeight, BmpBinary(1), BmpInfo, DIB_RGB_COLORS
Open "c:\temp.bmp" For Binary As #1
Put #1, , Bif
Put #1, , Bih
Put #1, , BmpBinary()
Close #1
以上是把一幅在内存中的位图保存到文件的代码,但当打开这幅位图之后,里面的画面是全黑的,请问给位高手我写错了哪里呢,
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货