Click to See Complete Forum and Search --> : Retrieving color of a pixel


mitz89
November 28th, 2006, 06:55 PM
Is it possible to retrieve the color of the pixel with given the x and y coordinates of the pixel without using a CDC?
I'm thinking like saving the bitmap into a memory then retrieve the color of the pixel with the given x and y coordinates getting the color from the memory. I saw the function GetDIBits. Still don't know if it is possible..
Need help.

ovidiucucu
November 29th, 2006, 08:52 AM
Yes, it's possible.
But just an aside question. Why want you to do that way, as long as using CDC::GetPixel is so easy?

mitz89
December 3rd, 2006, 08:52 PM
Thnx for the reply. It is because I don't want to show the image at first because First I want to change the size of the bitmap and then display it.
In this situation I used BITMAPINFO to retrieve the information about the bitmap. If any of you guys encountered the same problem here are the steps:
1. Open the bitmap using file open or CFile in my case;
2. read the bitmap using BITMAPINFO(also used CFile in reading)
After that you already have information about the bitmap. you could supply the index of the bitmap in the bmcolor under the BITMAPINFO to retrieve the color of the pixel.

Thanks again. :)