How to capture stage to bitmapdata?

30 views
Skip to first unread message

S.-C Lee

unread,
Dec 24, 2017, 8:10:35 PM12/24/17
to StageXL
I want to take a screenshot of the stage or any stage element of it

How can i do that?

thank you.

Bernhard Pichler

unread,
Dec 25, 2017, 5:42:04 AM12/25/17
to S.-C Lee, StageXL
Hi,

Yes you can render any DisplayObject (including the stage) to a so called RenderTexture. 
And you can create ab BitmapData from this RenderTexture.

var renderTexture = new RenderTexture(640, 480, Color.Transparent);
var canvas = renderTexture.canvas;
var matrix = renderTexture.quad.drawMatrix;
var renderContext = new RenderContextCanvas(canvas);
var renderState = new RenderState(renderContext, matrix);
displayObject.render(renderState);

var
bitmapData = new BitmapData.fromRenderTextureQuad(renderTexture.quad):
Hope this helps,
Bernhard



--
You received this message because you are subscribed to the Google Groups "StageXL" group.
Visit this group at https://groups.google.com/group/stagexl.
To view this discussion on the web visit https://groups.google.com/d/msgid/stagexl/8abb8a06-b58c-4c26-b197-1429ef7e6fd4%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages