grab a screenshot of the view

Software: Away3D 4.x

Tayyab, Member
Posted: 15 October 2012 11:15 PM   Total Posts: 72

How can i grab a screenshot of the whole view or an object placed in the view?

   

Avatar
jscamposcr, Newbie
Posted: 15 October 2012 11:57 PM   Total Posts: 20   [ # 1 ]

You can get the bitmap data of the stage:

var bitmapdata:BitmapData = new BitmapData(stage.stageWidthstage.stageHeight);

bitmapdata.draw(stage);

var 
bitmapDataABitmapData = new BitmapData(300250);

bitmapDataA.copyPixels(bitmapdata, new Rectangle(36020320240), new Point(00));

var 
myEncoder:JPGEncoder = new JPGEncoder(90);

var 
byteArray:ByteArray myEncoder.encode(bitmapDataA); 

In order to make this a downloadable JPG follow this tutorial:

http://snipplr.com/view/6653/

   

Tayyab, Member
Posted: 16 October 2012 12:52 AM   Total Posts: 72   [ # 2 ]

thank you so much , I will give it a try.

   

Tayyab, Member
Posted: 16 October 2012 03:15 AM   Total Posts: 72   [ # 3 ]

i did this to do a quick test. but its all blank (white).

var bitmapdata:BitmapData = new BitmapData(GVC.stage.stageWidthGVC.stage.stageHeight);
bitmapdata.draw(GVC.stage);
var 
bitmapDataABitmapData = new BitmapData(300250);
bitmapDataA.copyPixels(bitmapdata, new Rectangle(36020320240), new Point(00));
/*var myEncoder:JPGEncoder = new JPGEncoder(90);
var byteArray:ByteArray = myEncoder.encode(bitmapDataA);*/
var myImage:Bitmap = new Bitmap(bitmapDataA);
GVC.stage.addChild(myImage);
return; 
   

thatflashdude, Newbie
Posted: 19 October 2012 06:05 AM   Total Posts: 19   [ # 4 ]
Tayyab - 16 October 2012 03:15 AM

i did this to do a quick test. but its all blank (white).

i believe the reason is you can not take a bitmap screenshot of the stage because the stage3d stuff isnt on the display list at all.

instead you need to grab a screenshot using these apis

context3D.drawToBitmapData()
context3D.renderToTexture()

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display3D/Context3D.html#drawToBitmapData()

do a search on the away3d code for these methods and you will find an api that wraps around it..something called queuesnapshot

 

   

Ivan Moreno, Newbie
Posted: 19 October 2012 06:36 PM   Total Posts: 22   [ # 5 ]

Hi Tayyab,

thatFlashDude is right, it is not working because you are drawing the wrong layer and you have to do something little extra with your renderer to avoid buffers problems/stress (Because you must have to clean your buffers every single draw/frame, and if you keep cleaning them, there is not bitmap data to catch). Use the exact same approach of jscamposcr, something like this:

var bitmapData:BitmapData = new BitmapData(yourview.widthyourview.height);
 
           
yourview
.renderer.swapBackBuffer false;
yourview.render();
yourview.stage3DProxy.context3D.drawToBitmapData(bitmapData);
yourview.renderer.swapBackBuffer true;
 
                       
var bitmap:Bitmap = new Bitmap(bitmapData); 

Hope this is what you are looking for. smile

Best.

[Edit 23/10/2012] This is the original post that I wanted to share with you, but I couldn’t find it that day. I think you already asked in there. smile Thanks John. Away3D thread here.[/Edit]

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X