Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29282 Discussions

How do I get pixel color from bitmap?

dk418
Beginner
1,036 Views
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.
0 Kudos
1 Reply
Jugoslav_Dujic
Valued Contributor II
1,036 Views
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.
0 Kudos
Reply