flixel-addons icon indicating copy to clipboard operation
flixel-addons copied to clipboard

FlxScreenGrab doesn't match PrintScreen results

Open larsiusprime opened this issue 10 years ago • 4 comments

In a customized version of crashdumper, I dump a screenshot on crash, using FlxScreenGrab.

Here's FlxScreenGrab's output: screenshot

Here's the system's native PrintScreen: screenshot_printscreen

The FlxScreenGrab image's tileset has little artifacts in it -- perhaps because I'm using the "tileset smear trick" where you add borders to each tile to avoid cross-tile bleed. Also note that the flixel-ui elements are arbitrarily offset from the native screenshot.

FlxScreenGrab just looks like it does a naked draw dump from the stage, so how is this discrepancy even happening? It should be using the same draw logic as everything else, right?

larsiusprime avatar Jun 06 '14 17:06 larsiusprime

I think OpenFL might be to blame for these inaccuracies. I've noticed the same with draw()ing the content of a FlxCamera into a BitmapData.

Gama11 avatar Jun 06 '14 18:06 Gama11

Ah, so the problem is that draw() is basically saying "render the stage's components" or something? It's not a straight pixel-dump?

Is there any way to just grab the last set of pixels blitted to the screen?

larsiusprime avatar Jun 06 '14 18:06 larsiusprime

I talked to Joshua in the OpenFL slack:

  • draw() uses software instead of hardware rendering, so that's where the discrepancies might be coming from
  • in this particular case, there seem to floating point rounding errors (if you compare the two images, everything seems to be always one pixel or so off)
  • it might be possible to make a screenshot via OpenGL at low-level as a workaround (openfl.gl.GL.readPixels() / related forum thread)

Gama11 avatar Jun 06 '14 19:06 Gama11

GL.readPixels() causes all sorts of crashing. I'm not sure how to use that :(

larsiusprime avatar Jun 06 '14 20:06 larsiusprime