I need to store a grayscale bitmap with high precision, so it needs to be 32bit.
this is the code I use to create the BaseBitmap:
const Int32 pixelBytes = COLORBYTES_GRAYf;
const Int32 pixelBits = pixelBytes * 8;
if (bitmap->Init((Int32)_width, (Int32)_height, pixelBits, INITBITMAPFLAGS::GRAYSCALE) != IMAGERESULT::OK)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION, "Could not initialize BaseBitmap!"_s);
Float32 *buffer = NewMemClear(Float32, _width) iferr_return;
for (Int z = 0; z < _height; ++z)
for (Int32 x = 0; x < _width; ++x)
buffer[x] = (Float32)GetSomeMagicGrayscaleValue();
bitmap->SetPixelCnt(0, (Int32)z, (Int32)_width, (UChar*)buffer, COLORBYTES_GRAYf, COLORMODE::GRAYf, PIXELCNT::NONE);
And here is how I save the file:
bmp->Save(fn, FILTER_TIF, nullptr, SAVEBIT::USE32BITCHANNELS);
The file is created, and when I open it in Preview.app (I'm on macOS, obviously), the bitmap is correctly displayed. Nice! However, if I simply select it in the Finder, the preview never appears, the spinning dots stay there forever. Also, the created file seems to be the only image file on my computer that has the default bitmap icon.
I guess, something needs to be changed in my code. Or is macOS simply not able to display previews of 32bit grayscale images, even though Preview.app can do it?
Greetings, thanks for tips,
I somehow doubt, that there is something in your code, that is the reason for the problem, given how high-level the bitmap format interface of BaseBitmap is. So the remaining question would be: Is it MAXON's or Apple's fault? My answer is probably not what you are looking for, but it should address some problems:
Hi Frank, I confirm that it's a flaw of macOS. Creating a 32-bit grayscale image with an image-editing software and pressing the space-bar on the selected image just ends up with the same results.
Ah, great, thank for checking!
Then I don't need to worry about my bmp code