Does anyone have an example of using the ImageSnapshot.captureBitmapData function with a rotation matrix? This is the code I'm using:
var matrix:Matrix = new Matrix();
matrix.rotate(degreesToRadians(90));
var bitmapData:BitmapData = ImageSnapshot.captureBitmapData(textInput, matrix);
But unfortunately this throws an error on the following line in ImageSnapshot.as:
data = new BitmapData(scaledWidth, scaledHeight, true, 0x00000000); // <-- THROWS ERROR HERE AS scaledWidth / scaledHeight are extremely small numbers (-1-e16 etc)
data.draw(source, matrix, colorTransform,
blendMode, clipRect, smoothing);
}
finally
{
if (source is IUIComponent)
finishPrintObject(IUIComponent(source), normalState); // <-- ERROR THROWN HERE, BUT CAUSE OF ERROR IS ABOVE
}
What I'm trying to achieve is a rotated bitmap of a text input control (I'm trying to avoid embedding a font in the application). This code works just fine when I don't rotate the bitmap, but the minute I rotate it, it breaks.
Post-Accepted-Answer Edit
I was working with a loader class in my original problem, and I also wanted the text 270degrees - so here's the text which does that:
var matrix:Matrix = new Matrix();
matrix.rotate(Math.PI * 1.5);
matrix.translate(0, copyThis.width);
var bitmapData:BitmapData = ImageSnapshot.captureBitmapData(copyThis, new Matrix());
var rotatedBitmap : BitmapData = new BitmapData(bitmapData.height, bitmapData.width, false, 0xFFFF0000);
rotatedBitmap.draw(bitmapData, matrix);
loader.load(new Bitmap(rotatedBitmap));
Thank you!