944,175 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 8113
  • C++ RSS
Jul 24th, 2007
0

HDC's

Expand Post »
Hello everyone,

I have this code:

C++ Syntax (Toggle Plain Text)
  1. Image* newImage = Image::FromFile(szFileName);
  2. Bitmap image(50, 50);
  3. Graphics graphics(&image);
  4. HDC gfxHDC = graphics.GetHDC();
  5. graphics.DrawImage(newImage, 0, 0);
  6. int pixel, row;
  7. for (pixel = 1, row = 1; row <= 50; pixel++)
  8. 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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Fromethius is offline Offline
15 posts
since Jul 2007
Jul 24th, 2007
1

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.
Moderator
Reputation Points: 572
Solved Threads: 115
Mentally Challenged Mod.
WolfPack is offline Offline
1,559 posts
since Jun 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: why return an int from main?
Next Thread in C++ Forum Timeline: Q: in Link List (Daubly Linked List)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC