tags:

views:

119

answers:

1

I am using a library that has been ported to Windows from Linux. The library is used to read a terrain database and up to this point it has been used for simple queries; elevation, line-of-sight, etc. But it also has the ability to create bitmaps of the underlying terrain file that I'd like to take advantage of... The function I am using says it creates an "XY-Bitmap that can then be passed to XPutImage". I have displayed images in an MFC app in the past but I cannot get this specific bitmap to work. Is there a way to display such a bitmap in a WIN32 application? Or possible a WIN32 port of the XPutImage function? I'd even be willing to used Python if it has some support for this image type.

+1  A: 

An XY-bitmap has a bit depth of 1 bit. What you could try is use CreateBitmap() with a bit depth of 1 pixel, use GetDIBits() to get a pointer to the raw pixel data and copy the XY-bitmap over the pixel data with memcpy(). I'm not sure the row/col order is the same though.

If that doesn't work, it's easy to write a function that will scan the XY-bitmap and copy the values into a bitmap that you've created with CreateBitmap() - be it one with a 1-bit depth or a higher depth, depending on the rest of the bitmaps you're working with I presume. The method would be the same - use GetDIBits() to get to the raw bitmap data, select the bitmap into a DC when you're done copying, use BitBlt(), StretchBlt() or AlphaBlend() to display the bitmap onto your paint DC.

Roel