Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
please help me for that because i want that for my col.protect I thank you very and I wish to communicate with you thank you very much once again and I hope to answer quickly to my request
Posted

You need first to load the image and then, accessing every single pixel, change it to either black or white RGB values, depending on its current color.
An example on how to perform pixel access (modification included) is in the LockBits[^] LockBits method documentation.

A naive col_to_bw method could be:
C#
void col_to_bw( ref byte r, ref byte g, ref byte b )
{
  if ( r*r + g*g + b*b >= 48387) // 48387 = 127*127*3
  {
    r = g = b = 255;
  }
  else
  {
    r = g = b = 0;
  }
} 


of course you could do better.
 
Share this answer
 
v2
visit link
See Topic No 5: Grayscale
Image Processing using C#[^]

Happy Coding!
:)
 
Share this answer
 
Comments
SoMad 4-Apr-13 5:33am    
That is a great article. The only problem is that the OP asked for VB (.NET) code and the article code is C#. I think it is fine leaving it up to the OP to port the code to VB.

Soren Madsen
Aarti Meswania 4-Apr-13 5:36am    
yes it is easy to convert code c# to VB using online converters
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900