On 13/06/2013 at 06:57, xxxxxxxx wrote:
EDIT: a new post was created that focuses on the problems with Blit() mentioned afterwards (SDK Help / GeClipMap::Blit())
I'm trying to solve a similar task. I'm using a GeClipMap and preload it with a background image. Onto such background image I want to place additional images. So in principle the same as if you would work in Photoshop with many layers - having a background image in the lowest layer and stack additional images (partly transparent) on top of it.
From my understanding the Blit() method of GeClipMap would be the best choice for doing such task. You have a GeClipMap (=destination) and some additional GeClipMaps (sources). With GeClipMap::Blit() you can copy diverse sources into the destination. You can specify a destination position and a source rectangle, so you should be able to cut out fractions of a source and place it anywhere in the destination.
That's the theory - but now comes the bad part of the storry: Blit() doesn't seem to work - that's my experience (and maybe also from ScottA who had some tries last year (2012) trying to do some sprite animations). I'm using Cinema R13.061, C++, Windows 7.
Maybe Blit() works fine in your environment (other C4D release or in Python).
I use the following code snippets in my C++ Plugin:
In Plugin-Init() : 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 Plugin-Draw() :
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);
bd->DrawTexture(cmp1->GetBitmap(), padr, cadr, vnadr, uvadr, 4, DRAW_ALPHA::DRAW_ALPHA_FROM_IMAGE, DRAW_TEXTUREFLAGS_0);
So in my case cmp_red/green/blue are the source images and cmp1 is the destination image (initialized with the background image) which is finally drawn with BaseDraw::DrawTexture() into the editor view. I skipped the code for setting up the data structures padr+cadr+vnadr+uvadr (such code was already posted by ScottA in this forum and was very helpful for me - thanks ScottA). The only thing I see on the screen is the background image with a line from 0,0 to 100,100 and the "Hello" text. The red/green/blue images aren't shown (although I tried all possible BLIT-modes specified by the last parameter of Blit()). Also locating the Blit() calls after the TextAt() call didn't help.
When I draw the cmp_red/gree/blue via BaseDraw::DrawTexture(), I get them shown in the editor view, but DrawTexture doesn't provide the BLIT modes like Blit() and splitting all the drawing actions up by using two different classes (BaseDraw and GeClipMap) isn't nice.
It would be fine if this code is working for your task. Maybe you/someone else in this forum could give an answer if Blit() works generally fine (i.e. only I would have such problem, maybe caused by wrong usage) or if there's a known bug inside Blit().
PS: trying to get solved own problems over other persons posts is no good style. I hope this is ok, because the name of the topic fits perfectly and Blit() should be the right choice.