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.
29285 Discussions

How to create a bitmap from pixel data

michael_green
Beginner
494 Views

Hi All,

I have installed the LibTIFF freeware and can use it to read TIFF images and write bitmap files (I'm using some C code I found on the Web for this). But what I really want to be able to do is read the TIFF images directly into memory bitmaps for immediate display, etc. The core of the C code I have is:

for (j = 0; j < image_width; j++)
{
outbuf[j * 3] = TIFFGetB(buf);
outbuf[j * 3 + 1] = TIFFGetG(buf);
outbuf[j * 3 + 2] = TIFFGetR(buf);
}
fwrite(outbuf, 1, scansize, bmp);

which I will ultimately render into Fortran. But how do I write the image to a memory bitmap using these TIFFGetB, etc, functions?This doesn't seem to be a case for using a memory device context and drawing to that. I have seen hints and clues in examples using SetBitmapBits and SetDIBits, but they're all in C, which I really don't understand very well. What I really need is some advice on what is the right approach to take and perhaps a Fortran example. Can anybody help?

With many thanks in advance,

Mike

0 Kudos
1 Reply
Paul_Curtis
Valued Contributor I
494 Views
Quoting - michaelgreen
... This doesn't seem to be a case for using a memory device context and drawing to that. ...

I have not translated image data to BMP from another format, but I think the Windows mechanism for this requires you to create a memory DC, then create a bitmap within that DC (in the same size as your original image), and then use the SETPIXEL function in a loop to translate your data one point at a time.

0 Kudos
Reply