THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/10/2011 at 14:03, xxxxxxxx wrote:
Cinema 4D Version: 12
Language(s) : C++ ;
I try to open a floating 32-Bit format bitmap and to store it again. I succeed in opening and storing, but the image-data seems to be altered. I guess, that comes from the not very clear construction of a MultipassBitmap.
My first attempt was to create a 1x1 Pixel MultipassBitmap and then call the Init(..) method to load the given Filename. This always returns "Out of Memory" (which of course is not the case).
I also tried allocating a bigger initial image, which shouldn't be necessary, as data is purged on a new Init.
So my second attempt is to load the image first into a BaseBitmap and then wrap it with a MultipassBitmap wrapper. But as I thought, the initial loading into a BaseBitmap seems lossy. So after storing, I have darker Colors.
Here is the final attempt:
// source and dest are valid Filenames
if ( !source.Content() || !dest.Content() || source == dest)
Bool ret = FALSE;
// Load image
BaseBitmap *loader = NULL;
Bool ismovie = FALSE;
// actually, we call here BaseBitmap::Init ...
res = MultipassBitmap::Init(loader,source, -1L, &ismovie,NULL);// load the bitmap into loader
if (res != IMAGERESULT_OK)
GePrintF("Could not load image ... exiting ...");
bitmap = MultipassBitmap::AllocWrapper(loader); // Now wrap it ...
... right now .. do nothing here ...
// store the image
// Hahaaaa, I cant write 32-B-I-T-C-H-A-N-N-E-L-S here ... it will missinterprete the semantics :)
So, how do I correctly load a 32-Bit floating format image and store it again?
On 24/10/2011 at 06:04, xxxxxxxx wrote:
In Cinema 32 bit images are loaded as a PaintTexture. This is for historical reasons (BodyPaint's 32 bit painting abilities). You can extract the bitmap from the PaintTexture, manipulate it and save it as BaseBitmap. Loading is done via the SendPainterCommand function.
Here a simple example loading a 32 bit file and saving it as HDR file.
Bool MenuTest::Execute(BaseDocument *doc)
if (!fn.FileSelect(FILESELECTTYPE_IMAGES, FILESELECT_LOAD, "Load Image")) return FALSE;
PaintTexture *tex = NULL;
tex = (PaintTexture* )SendPainterCommand(PAINTER_LOADTEXTURE, doc, NULL, &bc);
if (!tex) return FALSE;
if (!bmp) return FALSE;
if (!tex->ReCalc(NULL,0,0,tex->GetBw(),tex->GetBh(),bmp,RECALC_NOGRID|RECALC_INITBMP,0)) return FALSE;
// do something with bmp, it contains the 32 bit image data
if (bmp->Save(fn, FILTER_HDR, &data, SAVEBIT_32b**chANNELS) != IMAGERESULT_OK)
GeOutString("Error saving image",GEMB_OK);
Please also check the paint_saver_test.cpp example.
On 24/10/2011 at 06:20, xxxxxxxx wrote:
Thank you a lot for the example, I guess I would have never figured that out ...
On 24/10/2011 at 06:45, xxxxxxxx wrote:
Yeah, it's not really obvious. I stumbled over this in the past too.