On 13/06/2013 at 09:02, xxxxxxxx wrote:
Cinema 4D Version: 13.061
Platform: Windows ;
Language(s) : C++ ;
Hello out there,
I'm currently trying to build a 2D-image which is composed from several individual images. The use case is like in Photoshop: having a background image in the bottom layer, stacking additional images on top of that background by using certain levels of transparency and blit-modes.
Doing that in 3D-space by stacking Plane objects with textures in a certain z-order to get the same visual result is no option for me.
After checking the classes BaseBitmap and BaseDraw I found that GeClipMap exactly offers what I need (including easy text+clipping support). Especially the method GeClipMap::Blit() should offer me the possibility to subsequently draw images (and also fractions of them) on top of each other by using different blit-modes.
It seems to me, that Blit() doesn't work after I tried lots of parameter combinations, changing values, moving the Blit() calls from the beginning towards the end within the BeginDraw/EndDraw section. I also added a BeginDraw/EndDraw section for each involved GeClipMap and performed some dummy drawing actions on those images - no success. Has anyone made other - successful - experiences with Blit() ? I found no examples/hints in the SDK or in this forum+Google.
I'm using a couple of GeClipMaps, one acting as background image, the other ones (containing some red/green/blue dummy content, some pixels are fully transparent, others are fully opaque) are drawn on top of the background, followed by some test operations like drawing a line plus text. The result is finally drawn into the editor view by using BaseDraw::DrawTexture() (used a code example from ScottA which works pretty fine - thanks to ScottA).
My C++ code looks like this:
In my Plugin class definition:
GeClipMap* cmp1; // Pointer to the working GeClipMap where all comes together
GeClipMap* cmp_red; // Ptr to GeClipMap which will contain a red test image
GeClipMap* cmp_green; // Ptr to GeClipMap which will contain a green test image
GeClipMap* cmp_blue; // Ptr to GeClipMap which will contain a blue test image
In my Plugin-Init() function: doing the Alloc + Init of the GeClipMaps
cmp1 = GeClipMap::Alloc();
cmp_red = GeClipMap::Alloc();
cmp_green = GeClipMap::Alloc();
cmp_blue = GeClipMap::Alloc();
res = cmp1->Init("d:\\Background_240x240.png",0, &ismovie);
res = cmp_red->Init("d:\\Red_100x100.png",0, &ismovie);
res = cmp_green->Init("d:\\Green_100x100.png",0, &ismovie);
res = cmp_blue->Init("d:\\Blue_100x100.png",0, &ismovie);
In my Plugin-Draw() function:
cmp1->Blit(10,10,(const GeClipMap&)cmp_red, 10,10, 80,80, GE_CM_BLIT::GE_CM_BLIT_COL);
cmp1->Blit(10,10,(const GeClipMap&)cmp_green, 10,10, 80,80, GE_CM_BLIT::GE_CM_BLIT_COPY);
cmp1->Blit(10,10,(const GeClipMap&)cmp_blue, 10,10, 80,80, GE_CM_BLIT::GE_CM_BLIT_FG);
... // setting up padr+cadr+vnadr+uvadr
bd->DrawTexture(cmp1->GetBitmap(), padr, cadr, vnadr, uvadr, 4, DRAW_ALPHA::DRAW_ALPHA_FROM_IMAGE, DRAW_TEXTUREFLAGS_0);
Within my Plugin-Init() I check the return values of all GeClipMap::Init() calls - all return OK.
Within my Plugin-Draw() everything works fine (text+line appears). The final DrawTexture() call paints the content of my cmp1 GeClipMap as texture onto a plane in 3D space - looks fine, but the expected output from any of the 3 subsequent Blit() calls is missing. I used different blit modes for each call to test if maybe one of them brings something on the screen (i.e. first into cmp1).
Drawing the GeClipMaps via DrawTexture too (one after another) works, but that's not what I want because the BaseDraw class doesn't provide the same powerful blend features as GeClipMap does.
Can anyone tell me if my code is buggy or post some working code?
Many thanks in advance.