Load and save a 32-Bit format
-
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:
User Information:
Cinema 4D Version: 12
Platform:
Language(s) : C++ ;---------
Hy there,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) goto Error; Bool ret = FALSE; // Load image IMAGERESULT res; BaseBitmap *loader = NULL; MultipassBitmap *bitmap; 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 ..."); goto Error; } bitmap = MultipassBitmap::AllocWrapper(loader); // Now wrap it ... if (!bitmap) goto Error; ... right now .. do nothing here ... // store the image bitmap->Save(dest,FILTER_TIF,NULL,SAVEBIT_32b**chANNELS); // 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?
Thank you,
maxx -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
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) { Filename fn; if (!fn.FileSelect(FILESELECTTYPE_IMAGES, FILESELECT_LOAD, "Load Image")) return FALSE; PaintTexture *tex = NULL; BaseContainer bc; bc.SetFilename(LOADTEXTURE_FILENAME, fn); tex = (PaintTexture* )SendPainterCommand(PAINTER_LOADTEXTURE, doc, NULL, &bc); if (!tex) return FALSE; AutoAlloc<BaseBitmap> bmp; 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 BaseContainer data; if (bmp->Save(fn, FILTER_HDR, &data, SAVEBIT_32b**chANNELS) != IMAGERESULT_OK) { GeOutString("Error saving image",GEMB_OK); return FALSE; } GePrint("saved"); return TRUE; }
Please also check the paint_saver_test.cpp example.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
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 ...
Cheers,
maxx -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 24/10/2011 at 06:45, xxxxxxxx wrote:
Yeah, it's not really obvious. I stumbled over this in the past too.
cheers,
Matthias