Code archives/Graphics/Simple screenshot function

This code has been declared by its author to be Public Domain code.

Download source code

Simple screenshot function by deps2005
Call this function to save a screenshot. It will not overwrite screenshots already taken.
Function take_screenshot()

	Local filename:String, padded:String
	Local num:Int = 0

	padded = num
	While padded.length < 3 
		padded = "0"+padded
	Wend
	filename = "screen"+padded+".png"
	
	While FileType(filename) <> 0
		num:+1

		padded = num
		While padded.length < 3 
			padded = "0"+padded
		Wend
		filename = "screen"+padded+".png"
	Wend

	Local img:tpixmap = GrabPixmap(0,0,GraphicsWidth(),GraphicsHeight())

	SavePixmapPNG(img, filename )
	
	Print "Screenshot saved as "+filename

EndFunction

Comments

Baystep Productions2005
Nice, but i like....

SaveBuffer(FrontBuffer(),"screen.bmp")



Perturbatio2005
Nice, but i like....
That's all very well if you're using B3D


Eikon2006
Just what I was looking for. Thanks


RepeatUntil2006
Yes, many thanks!! Very useful for me!


Leon Drake2006
excellent.. i modded the command lines to grab a specific area of the desktop. very cool for splash windows then having to use user32 functs skin the window


Dwapook2012
Awesome, thanks!


Code Archives Forum