Hi,
I am using GeUserArea::DrawBitmap()
to draw a 32-bit greyscale bitmap into a GeUserArea
in a GeDialog
. On macOS, the code works nicely in R20 - R25, but in C4D 2023, nothing happens. All my drawing operations in the GeUserArea
work as expected, but the DrawBitmap()
call does nothing.
This is how I create the bitmap:
AutoAlloc<BaseBitmap> bitmap;
const maxon::Int32 pixelBytes = COLORBYTES_GRAYf;
const maxon::Int32 pixelBits = pixelBytes * 8;
if (bitmap->Init((maxon::Int32)_width, (maxon::Int32)_height, pixelBits, INITBITMAPFLAGS::GRAYSCALE) != IMAGERESULT::OK)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION, "Could not initialize BaseBitmap!"_s);
auto populateBitmapWorker = [&bitmap, pixelBytes] (maxon::Int z)
{
iferr (maxon::Float32* bufferPtr = NewMem(maxon::Float32, _width))
return;
for (maxon::Int x = 0; x < _width; ++x)
{
// Get value between 0.0 and 1.0
const maxon::Float value = GetTheValue(x, z);
bufferPtr[x] = (maxon::Float32)value;
}
bitmap->SetPixelCnt(0, (Int32)z, (Int32)_width, (UChar*)bufferPtr, pixelBytes, COLORMODE::GRAYf, PIXELCNT::NONE);
DeleteMem(bufferPtr);
};
maxon::ParallelFor::Dynamic(0, _height, populateBitmapWorker);
Calling ShowBitmap()
to display the bitmap in the Picture Viewer works fine, it looks exactly as I'd expect.
Now, in GeUserArea::DrawMsg()
I want to draw the bitmap in a GeUserArea
in a GeDialog
.
theBitmapPtr
has been allocated, initialised, and populated by the above shown code.
OffScreenOn();
SetClippingRegion(x1, y1, x2, y2);
// Fill background with standard background color
DrawSetPen(COLOR_BG);
DrawRectangle(0, 0, GetWidth(), GetHeight());
// Draw the bitmap
DrawBitmap(theBitmapPtr, 20, 0, 500, 500, 0, 0, theBitmapPtr->GetBw(), theBitmapPtr->GetBh(), BMP_NORMAL);
Again, this works perfectly fine in R25 and older releases. After drawing the bitmap, I also draw some text, and that text still appears in C4D 2023. Just the bitmap is missing. Any ideas?
Sporadically (but not always), I get messages like this in the Xcode console:
2023-09-12 15:07:53.549687+0200 Cinema 4D[5384:86871] [net.maxon.cinema4d] CGImageCreate: invalid image bits/component: 8 bits/pixel 32 alpha info = kCGImageAlphaNoneSkipFirst
outofmemory [mac_gui_tools.mm(291)]
Also, it seems (but I'll double check to validate) that it only fails on macOS, but works on Windows.
In deed, it works on Windows, but not on macOS.
Thanks in advance!
Cheers,
Frank