Problem taking a screenshot in mojo2

Monkey Forums/Monkey Programming/Problem taking a screenshot in mojo2

MonoDesire(Posted 2016) [#1]
Hello!

I have just gone from mojo to mojo2. In mojo I used a method for grabbing the screen (taking a screenshot), a method I got from these forums. I fail to convert it into mojo2. Need some assistance. This is what it looks like now, the non-working version in mojo2:



(The reason for the *4 size for the DataBuffer size is that I read somewhere that it was needed. But maybe it isn't. The result is the same without it.)

I call the ScreenGrab method like this:

Local panelGrab:Image = ScreenGrab(canvas, RIGHT_HAND_TOP_PANEL_X, RIGHT_HAND_TOP_PANEL_Y, RIGHT_HAND_TOP_PANEL_WIDTH, RIGHT_HAND_TOP_PANEL_HEIGHT)


And I later use this code to draw the image to the screen:

canvas.SetColor(1.0, 1.0, 1.0)
canvas.DrawImage(panelGrab, RIGHT_HAND_TOP_PANEL_X, RIGHT_HAND_TOP_PANEL_Y)


What happens is that when I draw the image/screenshot, it it all black. So I am not sure whether there is a problem in the ScreenGrab method, or how I draw the image.

Any help is appreciated! :-)


ImmutableOctet(SKNG)(Posted 2016) [#2]
It's working for me just fine. Here's a psychedelic example. If that example works, then it's definitely not your system or Mojo 2. I'll be honest, I can't really see why your code isn't working. Unless you're drawing the screenshot 'Image' above (After) everything before your call to 'ReadPixels', anyway. If that were the case, you'd be endlessly copying black onto black.

EDIT: Apparently the image can't be mipmapped, so maybe that's it? Still, it works just fine without any extra flags.


MonoDesire(Posted 2016) [#3]
@ImmutableOctet(SKNG):

Thanks a lot for your code example! :-) That is really helpful, because I now have your working code to compare with. I need to go over my code again...


MonoDesire(Posted 2016) [#4]
@ImmutableOctet(SKNG):

Ah, good info about the flags. I will remove and try again.