I'm using the ImageSnapshot.captureImage() method to screen capture a map image which is 2305 pixels high and 1134 pixels wide. I'm then trying to clip that image to one which is 1100 pixels high and 775 pixels wide.
public function grabScreenMapImage2():void {
// use ppi of 100 for testing
var ppi = 100;
var mapHeightInPixels = 1100
var mapWidthInPixels = 775
var snapImage:ImageSnapshot = ImageSnapshot.captureImage(myMap, ppi, new JPEGEncoder());
var bitmapData:BitmapData = new BitmapData(mapWidthInPixels, mapHeightInPixels);
var pixels:ByteArray = new ByteArray();
pixels = snapImage.data;
pixels.position = 0;
var clipRect:Rectangle = new Rectangle(0,0,mapWidthInPixels, mapHeightInPixels);
bitmapData.setPixels(clipRect, pixels);
}
However, I'm getting an error #2030 - end of file was encountered on my call to setPixels(), and cannot for the life of me work out why.
Any help greatly appreciated!
Thanks,
DrBacchus
This works for me. I zoom in on the original bitmap, then crop it into a new image the same size as the old one.