How to Convert bitmap to black/white?

Peanutman

New member
Joined
Jun 18, 2005
Messages
3
Programming Experience
3-5
I have a bitmap loaded into memory by using the following code:

VB.NET:
Data = Clipboard.GetDataObject()
If Data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
    bmap = CType(Data.GetData(GetType(System.Drawing.Bitmap)), Image)
    Dim g As Graphics = Graphics.FromImage(bmap)
Endif

I would like to convert this bitmap in memory to a monochrome bitmap (black/white) and display it in a picbox.
The problem is i have no idea how to do this. Do i have to it pixel by pixel? or is there some cool VB.Net funtion to convert it to black/white.

Can anyone put me on the correct path pls.
Reinout,
 
Cool! Thank you extremely much.
The invert/grayscale subs work great.

I just have one question though. I understand the picture is displayed with that colormatrix applied to it. But what do the numbers in that matrix represent? That I don't fully understand.

And would be possible to convert the pic to full black-white (no grayscale, just black&white) by editing the matrix somehow?

Thanks extremely much, you have already helpen me a bunch.

Reinout,
 
Ok, as i haven't time to experiment with that i will give you a clue and i hope you'll find some logic.
Well, heres a clue - 1st split the image into Intensity, Saturation and Hue.
Then find an optimal line through the 3D table to convert lively color into boring grey and that's it.

Cheers ;)
 
Back
Top