PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Copying surface using CreateSurface?

FlatscreenFX · 07 Apr 2004, 09:59 UTC
I would like to copy just a particular part of area (not the whole thing) from one surface to another, and I have gone through the usage of CreateSurface and it doens't have this function .... but I remember someone here in the past said it is possible? :roll: am I missing sth here?

Thanks in advance if someone can give me a kick in the right direction.
Hi, I'm new to GapiDraw.
If you just want to draw a part of your first surface on the second one I think you can do it by using a Blt function:

mySurf2.Blt(pRect2, &mySurf1;, pRect1,dwFlags,pGDBltFx)

where mySurf1 is your "source" surface, mySurf2 is your target.
pRect1 is the part of the mySurf1 surface you want to draw,
pRect2 is the part of the mySurf2 surface where you want to draw.
(It would probably be better for the Rect1 and Rect2 rects to have the same dimensions).
Could some GapiDraw "guru" confirm? I don't want to say something wrong, I'm just a beginner...
I hope this is usefull.
Vincent.
It's correct, but you should use BltFast instead if you don't need to scale the blit. BltFast is also significantly faster...
GDuser · 08 Apr 2004, 01:06 UTC — hm ... u need this as well ..
Hi, I am trying to do what u are doing as well..

vincent was right in that u can blt on another surface using >>
mySurf2.Blt(pRect2, &mySurf1;, pRect1,dwFlags,pGDBltFx)

-----------------------------------------------------------------------------

but before that, u have to copy mySurf1 onto mySurf2 first, otherwise u will just print a blank screen, so ...

mySurf2.CreateSurface(&mySurf1;);
mySurf2.Blt(pRect2, &mySurf1;, pRect1,dwFlags,pGDBltFx)

//then BltFast as Johan suggested
pBackBuffer->BltFast(NULL, &mySurf2;, NULL, NULL, NULL);

-----------------------------------------------------------------------------

What I am doing is similar but I want to print a scaled image on the original one, but once i did this line "mySurf2.CreateSurface(&mySurf1;);" and BltFast to screen I get BOTH the original image AND the scaled image ..... (i just need to scaled one to display) ... im still trying to figure this out ...

Anyway, plesae do correct me if i am wrong here, i am a gapidraw newbie as well :oops:
Hi
Correct me if I'm wrong. You want surf1 to "contain" the original image and surf2 the scaled one. Then you want to blit surf1 and surf2 on top of it.
I tried this (and succeeded!!)
1st, create mySurf which contains the image to show.

mySurf.CreateSurface(GDSURFACE_SYSTEMMEMORY, "image.jpg");

then get the size of mySurf:
maxh = mySurf.GetWidth();
maxv = mySurf.GetHeight();

then create mySurf2 which size is a tenth of mySurf:
mySurf2.CreateSurface(GDSURFACE_SYSTEMMEMORY,(maxh/10),(maxv/10));

I then created a RECT I will use to blit on pBackBuffer:
myRect.left=50;
myRect.top=50;
myRect.right=50+(maxh/10);
myRect.bottom=50+(maxv/10);

I created a GDBLTFX struct with the rotationScale:
GDBltFx.dwRotationScale=10;

I did all this in InitInstance()
(everything is declared in my .h file)

then in ProcessNextFrame():

I blit the image on mySurf2 using the rotation scale:
mySurf2.Blt(NULL,&mySurf;,NULL,GDBLT_ROTATIONSCALE,&GDBltFx;);

I blit my source image:
pBackBuffer->Blt(NULL,&mySurf;,▭,GDBLT_KEYSRC,NULL);

I blit my scaled image on top of it in myRect:
pBackBuffer->Blt(&myRect;,&mySurf2;,NULL,GDBLT_KEYSRC,NULL);

And it works.

The problem is that I create mySurf with a given size, I imagine I could create it depending on the rotation scale (maxh*rotationscale/100). Same for myRect ( modify it with mySurf2.GetWidth() and GetHeight() ). But then if you want your user to be able to change the rotation scale you can't do anything in the InitInstance().

Am I correct?

I hope this helps.
Vincent.