Hi,
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:
maxon::Result<BaseBitmap*> MyClass::GetBitmap()
{
iferr_scope;
AutoAlloc<BaseBitmap> bitmap;
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);
}
DeleteMem(buffer);
return bitmap.Release();
}
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,
Frank