How do I get pixel color from bitmap?

How do I get pixel color from bitmap?

Hi,

I'm trying to read a bitmap file into memory and get the color of a pixel on the bitmap. I'm using Console application, and I tried all kinds of things to no avail.
Please help. It is not necessary that you see the bitmap on the screen, actually I prefer to do it all in the background.

Thanks in advance for your help.

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Take a look at my XFTGDI module. Briefly, you should:

- XCreateBitmap to load a bitmap from file;
- XMemoryDC to create a DC (canvas in memory) for it;
- XPlaceBitmap to place the bitmap onto the DC;
- XGetPixel to retrieve the pixel(s)

After that you can possibly call XSetPixel to change pixels, XGetBitmap to take the modified bitmap back and XSaveBitmap to save it. Don't forget to XDeleteDC when done.

Currently I didn't provide possibility to convert entire bitmap into a matrix of integers (which is far more efficient method); it's in plans.

Leave a Comment

Please sign in to add a comment. Not a member? Join today