Screenshots withh OpenFl?

Hi there,

Does anybody know if there is any way to take screenshots with openfl?

Thanks

Do you want a screenshot of the OpenFL application or of the entire desktop? What are your targets?

I am not sure how could you do that in html5 for example… but I am sure int he native targets you could do it over OpenGL or using a native binding. Android example in Java:

If you want to take screenshot of your app, you can draw main sprite to bitmap data and encode it:

var bitmapData = new BitmapData(screenWidth, screenHeight, false, 0);
bitmapData.draw(mainSprite);
var byteArray = bitmapData.encode(new Rectangle(0, 0, screenWidth, screenHeight), new PNGEncoderOptions());

than you can save this byteArray to file.

4 Likes

Sorry for being so vague. I meant taking a screenshot of the entire screen on a desktop application (windows/osx).

Thanks everybody.

This has some information for Windows:

It could be done with a native extension?

Hm, I’m not that versed in c++ or implementing native extensions for that matter, but it’s worth a look.

Thanks!