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.

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.

commented: c o r r e c t . +12
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.