Click to See Complete Forum and Search --> : Color to Black & White
amitabh
Jun 2nd, 2001, 09:30 PM
How do I change a bitmap being displayed from color to Black & white ?
Megatron
Jun 3rd, 2001, 11:20 AM
Not too sure on this, but I think you have to add the red, green and blue values together, and take the average of them (by diving them by 3).
Megatron
Jun 3rd, 2001, 11:27 AM
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Sub Command1_Click()
For x = 0 To Picture2.Width / Screen.TwipsPerPixelX
For y = 0 To Picture2.Height / Screen.TwipsPerPixelY
DoEvents
lColor = GetPixel(Picture2.hdc, x, y)
lRed = lColor Mod &H100
lGreen = Int(lColor / &H100) Mod &H100
lBlue = Int(lColor / &H10000) Mod &H100
t = Abs(Int((lRed + lGreen + lBlue) / 3))
SetPixel hdc, x, y, RGB(t, t, t)
Next y
Next x
End Sub
amitabh
Jun 8th, 2001, 03:02 PM
Thanks Megatron.
Btw, if you are working in Win 2000, you can use SetColorAdjustment to get a negative. You can even increase or decrease the brightness, gamma levels etc
Dirk
Oct 15th, 2001, 05:57 PM
How to then save this as a black and white bitmap?
TIA
Sastraxi
Oct 15th, 2001, 08:05 PM
I think VBEMPIRE has the right values, it's not just / 3.
jim mcnamara
Oct 15th, 2001, 10:24 PM
the CCIR recomended use for RGB -> monochrome conversion is luminance for use on monochrome monitors.
Y = 0.299*R + 0.587*G + 0.114*B
color = RGB(Y,Y,Y)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.