Skip to main content
Inspiring
August 28, 2012
Question

drawToBitmapData on iOS

  • August 28, 2012
  • 1 reply
  • 1202 views

Hi guys,

I just installed the latest version of Air hoping there was some changes on this, but I still have a problem so let me try to ask your help...

I have to render the stage3d on a bitmap, like a screenshot, and to do this I’m using the drawToBitmapData function, like the example on the API documentation.

This works fine on desktop but not on mobile, for example on my iPad3, where nothing is shown.

I noticed, reading around, that if put a call to the render function every frame, then also on ipad I see correctly the render result moved on a bitmap and pasted over the stage. But not using a single call, that is what I need.

So, with a function like this:

private function render(event:Event):void {

   stage3d.context3D.clear(0, 0, 0, 1);

   stage3d.context3D.drawTriangles(quadIndices);

   stage3d.context3D.drawToBitmapData(bd);

   stage3d.context3D.present();                       

  

   var bitmap:Bitmap = new Bitmap(bd);

   addChild(bitmap);

}

on mobile I have a working result only adding a ’addEventListener(Event.ENTER_FRAME, render)’

what do you think?

thanks!

This topic has been closed for replies.

1 reply

Inspiring
August 28, 2012

I'm gonna crazy...

it's not possible on iPad to render on a bitmap without to insert the function call into a onFrame loop for some absurd reason, so you can imagine the performance...

so at some point I have to remove that listener and I thought to wait until the last pixels of the bitmapData are different from zero (because there aren't event linked to drawToBitmapData to handle and wait for)... well, another issue... on ipad the getpixel always return zero and not the value I expect (like on desktop tests)

are there some other way to get a screenshot from stage3d on a damn iOS device?

Participant
September 10, 2014

Did you get this working?

User Unknow
Legend
September 10, 2014

really? You recreating each frame new Bitmap???

var bd : BitmapData = new BitmpData(w,h,false);

var bitmap:Bitmap = new Bitmap(bd);

addChild(bitmap);

private function render(event:Event):void {

...

stage3d.context3D.drawToBitmapData(bd);

...