An easy one I think...

BlitzPlus Forums/BlitzPlus Beginners Area/An easy one I think...

-=Darkheart=-(Posted 2005) [#1]
I would like to be able to capture the current image on the screen (equivlent of pressing printscreen) and save it straight to the desktop as either a jpeg (prefferred) or png. This is so simple I can't believe it hasn't been done before in Blitzplus but I can't find anything.

Anyone already done this or seen this done before?

Thanks,

Darkheart


Grey Alien(Posted 2005) [#2]
gfxGrab = CreateImage(GAME_WIDTH, GAME_HEIGHT)
GrabImage gfxGrab,0,0
SaveImage gfxGrab, CurrentDir()+"screenshot.bmp"
FreeImage gfxGrab

I had trouble getting the print screen key recognised, don't know why, so I used an F Key in the end. Note that the code above only saves it as a bmp. Also it uses CurrentDir(). You can change this to whatever path you want but to find out the current desktop path you probably need to check the registry or call a User32.dll function. The code archives will contain code to let you do this.


Regular K(Posted 2005) [#3]
Wouldnt SaveBuffer(backbuffer()) work also?


Grey Alien(Posted 2005) [#4]
I guess so, can't remember why I did that. I think it was from a help file actually.


-=Darkheart=-(Posted 2005) [#5]
Sorry just to make clear I don't want to capture what's going on in the application I want to capture whatever is on the screen at the time, including Windows background, other apps etc.

Darkheart


Beaker(Posted 2005) [#6]
Try saving the DesktopBuffer():
desk = DesktopBuffer()
SaveBuffer(desk,"test.bmp")



puki(Posted 2005) [#7]
Ooh, that is good - there isn't one of those in B3D - is it different/separate to front/back buffer?


-=Darkheart=-(Posted 2005) [#8]
LOL I didn't think it would be *THAT* easy, thanks Beaker, that will teach me to forget to update my docpacs.

Darkheart