temporarily saving the screen

BlitzMax Forums/BlitzMax Beginners Area/temporarily saving the screen

Ryan Burnside(Posted 2006) [#1]
Hi again,
could somebody show me how to save the current screen image into memory so I can use it as a backdrop for my highscore table?

Thanks you in advance.


Jim Teeuwen(Posted 2006) [#2]

'// Draw scene
....

'// store backbuffer in Pixmap
Local pm:TPixmap = GrabPixmap(0, 0, GraphicsWidth(), GraphicsHeight());

// or store in an Image'
Local img:TImage = createImage( GraphicsWidth(), GraphicsHeight(), 1, FILTEREDIMAGE | MASKEDIMAGE | DYNAMICIMAGE );
GrabImage(img, x, y );


Note that drawing a full screen-sized Pixmap to the screen is pretty damn slow. You may be better off using the Image method. Problem here is that the PixelFormat for the Image may not match the PixelFormat of the BackBuffer. This will produce some very odd colouring errors. I only get this error when using the DirectX7 driver though. OpenGL seems to work fine.


SculptureOfSoul(Posted 2006) [#3]
I'm using the CreateImage(), GrabImage() method for a function of mine and haven't run into any problems yet.

Well, I did have a problem when I tried to use GrabImage in a loop. I wanted to grab the background and then zoom in on it...well, I first grabbed the image, then increased the scale and drew the image again, grabbed it again, increased the scale and drew it again, etc. It didn't work though, I got this weird green flare effect instead. So instead I just grabbed the image once and then kept increasing the scale and redrawing.

Anyways, the method works and is plenty fast if you aren't going to be doing it often.


Ryan Burnside(Posted 2006) [#4]
Thanks guys I'll look into this.


Ryan Burnside(Posted 2006) [#5]
Thanks guys I'll look into this.


DannyD(Posted 2006) [#6]
Nice code. Is there a way to save a screenshot of the desktop itself not of the application?


Jim Teeuwen(Posted 2006) [#7]
You will either have to some tricky Win32 API calls, or perhaps MaxGUI let's you access the Desktop directly. I wouldntknow, as I don't use MaxGUI.


tonyg(Posted 2006) [#8]
This might do it


Ryan Burnside(Posted 2006) [#9]
OK sorry for the lag in reply, I have sucessfully use the grabimage command. You are right the colors seem darket than the pixmap. Is there a way to remidy this like create an image from a pixmap? I take it that pixmaps take longer to be drawn?