|
-
May 30th, 2009, 09:01 PM
#1
Picture image
I'd like to display a color image in black and white only ? What should I adjust ?
Thanks a lot
-----
-
May 31st, 2009, 01:56 AM
#2
Re: Picture image
Here is a link to convert a color bitmap into monochrome.
http://support.microsoft.com/default.aspx/kb/77282
-
June 1st, 2009, 08:41 AM
#3
Re: Picture image
 Originally Posted by yuenqi
I'd like to display a color image in black and white only ? What should I adjust ?
Thanks a lot
When you say black and white, do you mean monochrome (literally only black pixel or white pixel) or do you mean greyscale (like a black and white photo)?
If the former, see _Superman_'s link. If the latter, you'll have to go through each pixel and apply a formula to the red, green, and blue components, to convert to greyscale equivalent. The mathematical formula is:
grey=0.2125*red+0.7154*green+0.0721*blue;
To do this to an image, use something like this in a loop:
Code:
unsigned cr,rd,gn,bl,av;
for(;;) //do whatever to loop through your image here
{
cr=GetPixel(hdc,x,y);
rd=GetRValue(cr);
gn=GetGValue(cr);
bl=GetBValue(cr);
av=(rd*2125+gn*7154+bl*721)/10000;
SetPixel(hdc,x,y,RGB(av,av,av));
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|