Reputation: 579
I am looking for a way to create and display up to 200 stage screen shots. Currently I record each screen shot in a BitmapData object, then play through all of them. This approach works but it takes too much memory - crashes some browsers.
What is the best approach to solve this problem? Can I create .png's, .flv movie or somehow compress BitmapData?
Thanks!
Upvotes: 0
Views: 1000
Reputation: 1254
There more than one solution, but you can try one ot this (and combine):
make a lower resolution screencapture (scaling, see below)
transform your BitmapData into a ByteArray (via BitmapData.getPixels()) and call ByteArray.compress() (lossless compression)
compress image to JPEG ByteArray and defining the quality ratio depending number of capture you will do, resolution of it and memory space available (I'm not sure you can know, this last one) - I think it's one of the better way
Make a full size for the first one and for the rest, capture only changes and position (see how FlashPlayer debugger feature "Show Redraw Region" work)
if you working on an Air app, save BitmapData in temporary files
if it's possible, ask the user to unlock to a large amount of space for LocalSharedObject and write your data inside
Here, a sample code to make a capture with a scale ratio (ex: 100x200 DispObj -> 50x100 BitmapData)
var displayObject:DisplayObject;
var scale:Number = 0.5;
var bounds:Rectangle = displayObject.getBounds(displayObject);
var bitmapData:BitmapData = new BitmapData(uint((bounds.width + 0.5) * scale), uint((bounds.height + 0.5) * scale), true, 0);
bitmapData.draw(displayObject, new Matrix(scale, 0, 0, scale, -bounds.x * scale, -bounds.y * scale));
Upvotes: 2