DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   HDC's (http://www.daniweb.com/forums/thread84385.html)

Fromethius Jul 24th, 2007 12:59 pm
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.

WolfPack Jul 24th, 2007 1:17 pm
Re: HDC's
 
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.


All times are GMT -4. The time now is 10:26 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC