954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

HDC's

Hello everyone,

I have this code:

Image* newImage = Image::FromFile(szFileName);
   Bitmap image(50, 50);
   Graphics graphics(&image);
   HDC gfxHDC = graphics.GetHDC();
   graphics.DrawImage(newImage, 0, 0);
   int pixel, row;
   for (pixel = 1, row = 1; row <= 50; pixel++)
   if (GetPixel(gfxHDC, pixel, row) != RGB(255, 255, 255))


Anyways, whenever I use GetPixel, the IF statement ALWAYS runs. Even if it is a completely white image. I suspect that either DrawImage isn't drawing it onto gfxHDC or that GetPixel isn't reading the pixels from gfxHDC or I don't even know. The point is, it isn't working and I need some help.

Thanks.

Fromethius
Newbie Poster
15 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

Get the return value of GetPixel and RGB functions to seperate variables. See if the values are infact what you expect, rather than just comparing them.

Also read the remarks section of the GetPixel documentation.

WolfPack
Postaholic
Moderator
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You