Using GrabImage() to grab game screen

Monkey Forums/Monkey Programming/Using GrabImage() to grab game screen

MisterBull(Posted 2014) [#1]
Could somebody explain to me how to use mojo's grabimage to grab the game's screen? I need it for my pause screen and I cant seem to get it to work :P

kinda wish it functioned like the grabimage in BMax


Nobuyuki(Posted 2014) [#2]
Doesn't work like that. You gotta use ReadPixels.


darky000(Posted 2014) [#3]
As what Nobuyuki has said, you have to use ReadPixels if you want to capture an image on the game screen. The grabimage is used to grab an image from a spritesheet.


Midimaster(Posted 2014) [#4]
You can use this function:

....
MyImage:Image=ScreenGrab(40,40,200,300)
.....
Function ScreenGrab:Image(X%,Y%,Width%,Height%)
	If X<0 Error "Screen Grab Error"
	If Y<0 Error "Screen Grab Error"
	If (X+Width)>DeviceWidth() Error "Screen Grab Error"
	If (Y+Height)>DeviceHeight() Error "Screen Grab Error"

	PushMatrix
		SetMatrix 1,0,0,1,0,0
		Local ScreenShot:Image
		ScreenShot = CreateImage(Width,Height)
		Local pixels:Int[] =New Int[Width*Height]
		ReadPixels(pixels, X, Y, Width,Height)
		ScreenShot.WritePixels(pixels, 0, 0, Width,Height)
		Return ScreenShot
	PopMatrix
End



MisterBull(Posted 2014) [#5]
@midimaster

yeah, I found your code elsewhere in the forums and put it to good use.

to you, and everyone else in this topic: thanks for your help :)