MultipassBitmap Initialising
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/03/2005 at 09:28, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 9.1
Platform: Windows ; Mac OSX ;
Language(s) : C++ ;---------
How do we initialise our own MultipassBitmaps?Currently no matter what I do my MultipassBitmap layers refuse to take any image information (the layers exist, there appear to be valid pointers, the layers have their parameter data name etc, they just can't be drawn to, initialisation of the layers makes no difference).
Is this user error, or a bug in the API?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/03/2005 at 09:48, xxxxxxxx wrote:
I can't confirm this error. The following code correctly writes an 8x8 tiff file:
AutoFree<MultipassBitmap> mpb(MultipassBitmap::Alloc(8,8,MODE_RGB)); mpb->SetPixelCnt(0,0,8, "abcdefgh", 1, MODE_GREY8, FALSE); mpb->SetPixelCnt(0,1,8, "ijklmnop", 1, MODE_GREY8, FALSE); mpb->SetPixelCnt(0,2,8, "qrstuvwx", 1, MODE_GREY8, FALSE); mpb->SetPixelCnt(0,3,8, "yzABCDEF", 1, MODE_GREY8, FALSE); mpb->SetPixelCnt(0,4,8, "GHIJKLMN", 1, MODE_GREY8, FALSE); mpb->SetPixelCnt(0,5,8, "OPQRSTUV", 1, MODE_GREY8, FALSE); mpb->SetPixelCnt(0,6,8, "WXYZ1234", 1, MODE_GREY8, FALSE); mpb->SetPixelCnt(0,7,8, "567890,.", 1, MODE_GREY8, FALSE); mpb->Save(GeGetStartupPath() + Filename("test.tif"), FILTER_TIF, 0, SAVEBIT_MULTILAYER);
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/03/2005 at 13:04, xxxxxxxx wrote:
Here's the code I'm currently using. i'm trying to clone the render multipass from within a videopost (this is called in vps->vp==VP_FRAME && !vps->open). It's not having any of it!
I know that the original rgba buffer multipass bitmap (rgba_bitmap) is full at this point, but my duplicate (rgba_clone) remains steadfastly empty.
//------------------- //retrieve the buffer VPBuffer *rgba_buffer=vps->render->GetBuffer(VPBUFFER_RGBA,0); if (!rgba_buffer) return RAY_NOMEM; //------------------- //cast to multipass bitmap MultipassBitmap *rgba_bitmap=(MultipassBitmap* )rgba_buffer; //------------------- //allocate our clone //rgba_clone is declared in the class header as MultipassBitmap *rgba_clone LONG bitmode=rgba_bitmap->GetParameter(MPB_COLORMODE).GetLong(); if (rgba_clone) { MultipassBitmap::Free(rgba_clone); rgba_clone=NULL; } rgba_clone=MultipassBitmap::Alloc(rgba_bitmap->GetBw(),rgba_bitmap->GetBh(),bitmode); if (!rgba_clone) return RAY_NOMEM; LONG pixel_count=rgba_bitmap->GetBw()*rgba_bitmap->GetBh(); LONG layercount=rgba_bitmap->GetLayerCount(); MultipassBitmap *clone_layer=NULL; //--------------------- //iterate through layers and clone the data for (i=0;i<layercount;i++) { //------------------- //retrieve the individual layer in the rgba bitmap MultipassBitmap *bitmap_layer=rgba_bitmap->GetLayerNum(i); if (!bitmap_layer) return RAY_NOMEM; bitmode=bitmap_layer->GetParameter(MPB_COLORMODE).GetLong(); //------------------- //add and retrieve a corresponding layer in our multipass bitmap clone_layer=NULL; if (i>0) { clone_layer=rgba_clone->AddLayer(BMP_INSERTLAST,bitmode); } else { clone_layer=rgba_clone->GetLayerNum(0); if (!clone_layer) clone_layer=rgba_clone->AddLayer(NULL,bitmode); } if (!clone_layer) return RAY_NOMEM; //------------------- //copy the layers parameters clone_layer->SetParameter(MPB_SHOW,bitmap_layer->GetParameter(MPB_SHOW)); clone_layer->SetParameter(MPB_SAVE,bitmap_layer->GetParameter(MPB_SAVE)); clone_layer->SetParameter(MPB_PERCENT,bitmap_layer->GetParameter(MPB_PERCENT)); clone_layer->SetParameter(MPB_BLENDMODE,bitmap_layer->GetParameter(MPB_BLENDMODE)); clone_layer->SetParameter(MPB_COLORMODE,bitmode); clone_layer->SetParameter(MPB_BITMAPTYPE,bitmap_layer->GetParameter(MPB_BITMAPTYPE)); clone_layer->SetParameter(MPB_NAME,bitmap_layer->GetParameter(MPB_NAME)); clone_layer->SetParameter(MPB_DPI,bitmap_layer->GetParameter(MPB_DPI)); clone_layer->SetParameter(MPB_USERID,bitmap_layer->GetParameter(MPB_USERID).GetLong()); clone_layer->SetParameter(MPB_USERSUBID,bitmap_layer->GetParameter(MPB_USERSUBID)); //------------------- //copy the layers bitmap data void *ldat=GeAlloc(clone_layer->GetBt()*pixel_count); bitmap_layer->GetPixelCnt(0,0,pixel_count,ldat,1,bitmode,FALSE); clone_layer->SetPixelCnt(0,0,pixel_count,ldat,1,bitmode,FALSE); GeFree(ldat); ldat=NULL; }
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/03/2005 at 13:11, xxxxxxxx wrote:
Try setting one line at a time instead of the whole 'pixelcount'. (The latter doesn't seem to work here. It stops at the right edge.)
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/03/2005 at 13:30, xxxxxxxx wrote:
unfortunately the clone bitmap still remains empty even with setting a line or even a pixel at a time.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/03/2005 at 14:29, xxxxxxxx wrote:
ok, and with help from Mikael we've managed to work out where I was going wrong!
here's the complete code (in case anyone else ever needs to be able to duplicate a multipass bitmap in a videopost. this could be improved somewhat, but it's readable
if (vps->vp==VP_RENDER && !vps->open && *vps->error==RAY_OK && !vps->thread->TestBreak()) { //------------------- //retrieve the buffer VPBuffer *rgba_buffer=vps->render->GetBuffer(VPBUFFER_RGBA,0); if (!rgba_buffer) return RAY_NOMEM; RayParameter *ray = vps->vd->GetRayParameter(); // only in VP_INNER & VP_RENDER if (!ray) return RAY_NOMEM; LONG i=0,o=0,x1,y1,x2,y2; x1 = ray->left; y1 = ray->top; x2 = ray->right; y2 = ray->bottom; LONG width=x2-x1; LONG height=y2-y1; //------------------- //cast to multipass bitmap MultipassBitmap *rgba_bitmap=(MultipassBitmap* )rgba_buffer; if (!rgba_bitmap) return RAY_NOMEM; //------------------- //allocate our clone //rgba_clone is declared in the class header as MultipassBitmap *rgba_clone LONG bitmode=rgba_bitmap->GetParameter(MPB_COLORMODE).GetLong(); if (rgba_clone) { MultipassBitmap::Free(rgba_clone); rgba_clone=NULL; } rgba_clone=MultipassBitmap::Alloc(rgba_bitmap->GetBw(),rgba_bitmap->GetBh(),bitmode); if (!rgba_clone) return RAY_NOMEM; LONG pixel_count=rgba_bitmap->GetBw()*rgba_bitmap->GetBh(); LONG layercount=rgba_bitmap->GetLayerCount(); MultipassBitmap *clone_layer=NULL,*previous_layer=NULL; //--------------------- //iterate through layers and clone the data for (i=0;i<layercount;i++) { //------------------- //retrieve the individual layer in the rgba bitmap MultipassBitmap *bitmap_layer=rgba_bitmap->GetLayerNum(i); if (!bitmap_layer) return RAY_NOMEM; bitmode=bitmap_layer->GetParameter(MPB_COLORMODE).GetLong(); //------------------- //add and retrieve a corresponding layer in our multipass bitmap previous_layer=clone_layer; clone_layer=NULL; if (i>0) { clone_layer=rgba_clone->AddLayer(previous_layer,bitmode); } else { clone_layer=rgba_clone->GetLayerNum(0); if (!clone_layer) clone_layer=rgba_clone->AddLayer(NULL,bitmode); } if (!clone_layer) return RAY_NOMEM; //------------------- //copy the layers parameters clone_layer->SetParameter(MPB_SHOW,bitmap_layer->GetParameter(MPB_SHOW)); clone_layer->SetParameter(MPB_SAVE,bitmap_layer->GetParameter(MPB_SAVE)); clone_layer->SetParameter(MPB_PERCENT,bitmap_layer->GetParameter(MPB_PERCENT)); clone_layer->SetParameter(MPB_BLENDMODE,bitmap_layer->GetParameter(MPB_BLENDMODE)); clone_layer->SetParameter(MPB_COLORMODE,bitmode); clone_layer->SetParameter(MPB_BITMAPTYPE,bitmap_layer->GetParameter(MPB_BITMAPTYPE)); clone_layer->SetParameter(MPB_NAME,bitmap_layer->GetParameter(MPB_NAME)); clone_layer->SetParameter(MPB_DPI,bitmap_layer->GetParameter(MPB_DPI)); clone_layer->SetParameter(MPB_USERID,bitmap_layer->GetParameter(MPB_USERID).GetLong()); clone_layer->SetParameter(MPB_USERSUBID,bitmap_layer->GetParameter(MPB_USERSUBID)); //------------------- //copy the layers bitmap data void *ldat=GeAlloc(bitmode*width); for (o=0;o<height;o++) { bitmap_layer->GetPixelCnt(0,o,width,ldat,1,bitmode,FALSE); clone_layer->SetPixelCnt(0,o,width,ldat,1,bitmode,FALSE); } GeFree(ldat); ldat=NULL; } clone_layer->Save(GeGetStartupPath() + Filename("clone.tif"), FILTER_TIF, 0, SAVEBIT_MULTILAYER); rgba_bitmap->Save(GeGetStartupPath() + Filename("original.tif"), FILTER_TIF, 0, SAVEBIT_MULTILAYER); } return RAY_OK;
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/03/2005 at 21:54, xxxxxxxx wrote:
oops, i spoke too soon. a minor ammendment is needed for this to work correctly. the get & setpixel counts need to have the correct byte increment (bitmode) and the width of course needs to be incremented by 1.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/03/2005 at 05:01, xxxxxxxx wrote:
Thanks for this mdme!