|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Private Declare PtrSafe Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, ByRef lpObject As Any) As Long
Private Sub ReColorBMP(hBM As Long, Size As Long, RecolorType As Long)
Dim X As Long
Dim Y As Long
Dim RV As Long
Dim BM As Bitmap
Dim ImageData() As Byte
Dim ColorTable(0 To 255) As RGBQUAD
GetObject hBM, LenB(BM), BM
ReDim ImageData(0 To (BM.bmBitsPixel \ 8) - 1, 0 To BM.bmWidth - 1, 0 To BM.bmHeight - 1)
GetBitmapBits hBM, BM.bmWidthBytes * BM.bmHeight, ImageData(0, 0, 0)
If RecolorType > 0 Then
DefineColorTable ColorTable, RecolorType
For X = 0 To BM.bmWidth - 1
For Y = 0 To BM.bmHeight - 1
RV = RGB(ImageData(2, X, Y), ImageData(1, X, Y), ImageData(0, X, Y))
If RV <> 16777215 And RV <> 0 Then
RV = ImageData(2, X, Y)
ImageData(2, X, Y) = ColorTable(RV).rgbRed
ImageData(1, X, Y) = ColorTable(RV).rgbGreen
ImageData(0, X, Y) = ColorTable(RV).rgbBlue
End If
Next Y
Next X
SetBitmapBits hBM, BM.bmWidthBytes * BM.bmHeight, ImageData(0, 0, 0)
End If
End Sub
hBM和size都是有值进入的,但是ref出来的值一直为空,请大神解惑~,hBM的值类型不可以为long么?
|
|