[Gambas-user] how copy the screen to memory on a sdl project

Tobias Boege taboege at ...626...
Sat Jul 19 12:55:16 CEST 2014


On Sat, 19 Jul 2014, Jack wrote:
> Le 18/07/2014 15:09, Tobias Boege a ?crit :
> > By "screen" you mean the whole desktop, not just your SDL window, right?
> 
> Excuse me Tobi. I was not very clear. Screen for me is only sdl window. 
> it's the working screen defined by the Gambas program.
> 

OK. Next thing to notice is that you are using the Draw event to paint your
window. To grab a rectangle (x,y,w,h) from your screen you can do something
similar to:

 - define a Private $bMakeScreenshot As Boolean and set it to True whenever
   you want to make a screenshot (set it to False after every Draw event)
 - define Private $iX, $iY, $iW, $iH As Integer which specify the rectangle
   to grab in case $bMakeScreenshot is True.
 - in your Draw event handler, if $bMakeScreenshot is True, do not draw
   immediately to the screen but to an intermediate Image object. Then draw
   the Image to the screen and extract your screenshot from the Image.

Once you set $bMakeScreenshot, you will get a screenshot of the next frame.

HOWEVER, as I was trying to implement this (see attached project), I saw in
the documentation that gb.sdl is currently (?) not capable of drawing to an
Image. Without that, I fear that you can't do that with gb.sdl - at least I
am out of ideas at this point. I bet it would work if only we were able to
draw to an Image...

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sdltest-0.0.1.tar.gz
Type: application/octet-stream
Size: 5147 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20140719/1857b22d/attachment.obj>


More information about the User mailing list