Unable to create snapshot of Canvas
In my application a canvas object has height = 90 px & width = 86400 px (indicating number of seconds in a day [60 * 60 * 24] ). The canvas is scrollable and the user can add or delete components in that.
Now, I want to have snapshot of the whole canvas & shrink it to size 910x30 to draw t开发者_JAVA技巧aken snapshot in another canvas.
Can anybody tell me how to take snapshot of such large Component?
I have tried to take snapshot in BitmapData object but as it max width is 2880 can not give whole canvas snapshot.
Is there any other Idea possible, if yes please let me know.
Suggestions are welcome.
I haven't tested this out, but what if you dismissed the BitmapData all together and just took the result straight from the client computer? like this:
var imgSnapshot:ImageSnapshot = ImageSnapshot.captureImage(savableCanvas,72,new PNGEncoder(),false);
var bArray:ByteArray = imgSnapshot.data;
var fileRef:FileReference = new FileReference();
fileRef.save(bArray,"mySavedImage.png");
Also, are there typos on your question, 86,400 pixels is a hell of a lot of data to be dealing with and you should probably be handling this with some server-side code and tiling techniques (think, Google Maps)... this way if you were say using php, you could use imagick and crop the needed dynamically-created-section. Now if it were 8,640px, then that's another story, look into BitmapDataUnlimited on Google Code. And don't worry, it's commercial friendly. However, it does come at a price, that large of a canvas needs to be managed quite well, and discarded immediately after it's use is threw considering that a 12k x 12k bitmapData object is said to be at least 1GB of memory...
You could take multiple snapshots of your large Canvas, scale down and then stitch them back together. But any kind of bitmap capture for a component that large is going to be very intensive.
You may also be able to try to set the scaleX/scaleY property on the canvas so that it fits to your 910x30 size and then doing the snapshot. That way Flash would scale for you.
精彩评论