2002.01.16 11:07 "How to interpret 16-bit GrayScale image?", by Bad Badtz

2002.01.21 13:19 "Re: How to interpret 16-bit GrayScale image?", by Martí Maria


Oh, well, you have discovered windows bitmaps are very limited when trying to store anything but a few formats. A windows bitmap cannot store 16 bits, for example. You have two workarounds.

One, ignore completly the windows bitmap stuff, and store the image in your own memory block/storage scheme. This is the best solution but I'm afraid it requeres a lot of work, since you cannot use GDI anymore.

Two, convert 16 to 8 bits. This is going to loose information, but you will get compatibility with all GDI functions.

Bitmap does NOT accept grayscale as type, but there is a clean trick. Just build the bitmap as a palette one, and then add a palette of 256 grays. This palette should be built using a gamma curve, else you will get even few grays on display. At this point your bitmap will behave as a grayscale of 8 bps. Then convert from 16 bps to 8 bps by dividing by 257. (sic, 257. NOT 256)

There are other solutions, like to emulate grayscale by using close-neutral colors, or use icc profiles to build accurate conversion, but these are really complex ways to get only a slightly better results.

Hope this helps,