On 14/12/2013 at 03:10, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14
Platform: Windows ;
Language(s) : C++ ;
---------
Hi Folks,
I have a function that returns a bitmap. The draw and returned bitmap is all fine, but I'm a little unsure on how to deal with the alpha bitmap that is used in it, and in particular on how to free/release it without affecting the returned bitmap. Can an AutoAloc<BaseBitmap> be used for the internal channel?
BaseBitmap* MyFuntion(void)
{
AutoAlloc<BaseBitmap> BMP;
BaseBitmap *Alpha = BaseBitmap::Alloc();
Alpha = BMP->GetInternalChannel();
Alpha = BMP->AddChannel(TRUE,TRUE);
// DO ALL THE DRAWS ETC HERE
return BMP.release();
}
Using "Alpha = NULL;" and "BaseBitmap::Free(Alpha);" after the drawing and before the return prevents it from working correctly. I can just leave the bitmap without NULL/Freeing it etc., but doesn't that leave the alpha bitmap pointlessly in memory after the function has finished?
Or can an AutoAlloc'd bitmap be used instead? How are the GetInternalChannel calls done in this case?
Or.. does the final BMP.release() cover all of that for me in the return call?
Cheers,
WP.