1 Attachment(s)
[RESOLVED] About ScaleGray
i have these function for do scalegray:
Code:
Private Type BITMAPINFO
bmiHeader As BITMAPINFOHEADER
bmiColors As RGBQUAD
End Type
Private Const DIB_RGB_COLORS = 0&
Private Const BI_RGB = 0&
Private Const pixR As Integer = 3
Private Const pixG As Integer = 2
Private Const pixB As Integer = 1
'Put the image black and white
Public Sub MakeGray(ByVal picColor As PictureBox)
Dim bitmap_info As BITMAPINFO
Dim pixels() As Byte
Dim bytes_per_scanLine As Integer
Dim pad_per_scanLine As Integer
Dim X As Integer
Dim Y As Integer
Dim ave_color As Byte
' Prepare the bitmap description.
With bitmap_info.bmiHeader
.biSize = 40
.biWidth = picColor.ScaleWidth
' Use negative height to scan top-down.
.biHeight = -picColor.ScaleHeight
.biPlanes = 1
.biBitCount = 32
.biCompression = BI_RGB
bytes_per_scanLine = ((((.biWidth * .biBitCount) + 31) \ 32) * 4)
pad_per_scanLine = bytes_per_scanLine - (((.biWidth * .biBitCount) + 7) \ 8)
.biSizeImage = bytes_per_scanLine * Abs(.biHeight)
End With
' Load the bitmap's data.
ReDim pixels(1 To 4, 1 To picColor.ScaleWidth, 1 To picColor.ScaleHeight)
GetDIBits picColor.hdc, picColor.Image, _
0, picColor.ScaleHeight, pixels(1, 1, 1), _
bitmap_info, DIB_RGB_COLORS
' Modify the pixels.
For Y = 1 To picColor.ScaleHeight
For X = 1 To picColor.ScaleWidth
ave_color = CByte((CInt(pixels(pixR, X, Y)) + _
pixels(pixG, X, Y) + _
pixels(pixB, X, Y)) \ 3)
pixels(pixR, X, Y) = ave_color
pixels(pixG, X, Y) = ave_color
pixels(pixB, X, Y) = ave_color
Next X
Next Y
' Display the result.
SetDIBits picColor.hdc, picColor.Image, _
0, picColor.ScaleHeight, pixels(1, 1, 1), _
bitmap_info, DIB_RGB_COLORS
picColor.Picture = picColor.Image
End Sub
the picturebox that i use are both pixel scalemode.
in images(*.gif(animated and static); *.ico;*.ani;*.cur and others) is working ok.
but i'm using a strips images too(is a big image that have very subimages and the plus images can do an animation). for use these subimages i use the transparentbl() api function.
in these images(strips) these function doesn't the normal way, can anyone
heres the image for see...
has you can see the 1st, 2nd and 4th are ok, but the 3rd isn't...
can anyone explain to me why?
thanks