Convert color BMP to black and white BMP 
Author Message
 Convert color BMP to black and white BMP

Hello,

Does anyone know how to convert color BMP to B&W? I tried to run over
the pixels and to change each one accroding to its RGB value
( R+G+B>512 = Black, otherwise white ), but when I save it with Save
method of the PictureBox control, it still saves it as RGB 24 bit
 ( not true B&W BMP format ).

Any help is more then welcome...

Thanks.
Mark Bar,



Tue, 25 Jun 2002 03:00:00 GMT  
 Convert color BMP to black and white BMP

Quote:

>Hello,

>Does anyone know how to convert color BMP to B&W? I tried to run over
>the pixels and to change each one accroding to its RGB value
>( R+G+B>512 = Black, otherwise white ), but when I save it with Save
>method of the PictureBox control, it still saves it as RGB 24 bit
> ( not true B&W BMP format ).

>Any help is more then welcome...

>Thanks.
>Mark Bar,


You will probably find the answer to changing the .bmp file format at
http://www.wotsit.org/. I don't know how to persuade a PictureBox that
it has been changed to Black and White but, looking at the properties,
I would guess that .Palette is you best bet. You may also be
interested in the following post which arose via a different thread in
this group. I think that selecting a threshold after this conversion
would yield a better black and white image.
_______________________________________________________
A couple of guys in another forum came up with two great solutions;
I'll repost them here:
[1st solution (equivalent to yours) snipped]

a more accurate measure takes into account the
fact that green looks brighter than red, and much brighter than blue:

Function GreyScale (ByVal Colr As Long) As Integer
' Takes a long integer color value and converts it
' to an equivalent grayscale value between 0 and 255
  Dim R As Long, G As Long, B As Long

  ' Break up long color value into red, green, blue
  R = Colr Mod 256
  Colr = Colr \ 256
  G = Colr Mod 256
  Colr = Colr \ 256
  B = Colr Mod 256

  ' Find equivalent grayscale value, 0 - 255.
  GreyScale = 76 * R / 255 + 150 * G / 255 + 28 * B / 255

End Function

Jim Deutch



Tue, 25 Jun 2002 03:00:00 GMT  
 Convert color BMP to black and white BMP
Hello David,

Thanks for the help. Despite the fact that I searched the Internet for
an OCX that knows how to do it, I came out with nothing.

It should be simple, shouldn't it ? :-))

Mark.

On Fri, 07 Jan 2000 23:59:28 +1100, David Segall

Quote:


>>Hello,

>>Does anyone know how to convert color BMP to B&W? I tried to run over
>>the pixels and to change each one accroding to its RGB value
>>( R+G+B>512 = Black, otherwise white ), but when I save it with Save
>>method of the PictureBox control, it still saves it as RGB 24 bit
>> ( not true B&W BMP format ).

>>Any help is more then welcome...

>>Thanks.
>>Mark Bar,

>You will probably find the answer to changing the .bmp file format at
>http://www.wotsit.org/. I don't know how to persuade a PictureBox that
>it has been changed to Black and White but, looking at the properties,
>I would guess that .Palette is you best bet. You may also be
>interested in the following post which arose via a different thread in
>this group. I think that selecting a threshold after this conversion
>would yield a better black and white image.
>_______________________________________________________
>A couple of guys in another forum came up with two great solutions;
>I'll repost them here:
>[1st solution (equivalent to yours) snipped]

>a more accurate measure takes into account the
>fact that green looks brighter than red, and much brighter than blue:

>Function GreyScale (ByVal Colr As Long) As Integer
>' Takes a long integer color value and converts it
>' to an equivalent grayscale value between 0 and 255
>  Dim R As Long, G As Long, B As Long

>  ' Break up long color value into red, green, blue
>  R = Colr Mod 256
>  Colr = Colr \ 256
>  G = Colr Mod 256
>  Colr = Colr \ 256
>  B = Colr Mod 256

>  ' Find equivalent grayscale value, 0 - 255.
>  GreyScale = 76 * R / 255 + 150 * G / 255 + 28 * B / 255

>End Function

>Jim Deutch



Thu, 27 Jun 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. 16 color BMP file reformat to Monochron BMP

2. BMP 24-bit to BMP 1-bit converting

3. Convert 16 bit bmp to 24 bit bmp

4. Convert 24bit Bmp to 16bit BMP

5. Saving API Drawings to a BMP or Converting from WMF to BMP

6. convert 24bit Bmp to 240 color image (YES 240)

7. convert into black and white

8. help - Memory DC Bitmaps Black&white instead of color

9. Create White (blank) BMP in code?

10. How do I print a picture/bmp correctly, I keep getting a black rectangle

11. BMP - change color based on form's background color

12. Change BMP Back Color and Fore Color

 

 
Powered by phpBB® Forum Software