I’m trying to draw the contents of a BitmapData into another one, yet to be created.
But before drawing I need to scale and rotate the image, and the draw it.
My problem is that I don’t know the size that the BitmapData will have after the transformation, so I can’t create the new one to draw on it.
This method shows what I mean:
public function getTransformedBitmapData(origin:BitmapData):BitmapData
{
var matrix:Matrix = new Matrix();
// ajusting the anchor point and rotating
matrix.translate(-origin.width / 2, -origin.height / 2);
matrix.rotate(Math.PI / 4); // 45 deg
matrix.translate(origin.width / 2, origin.height / 2);
// scaling
matrix.scale(1.5, 1.5);
// Calculating the size of the new BitmapData
var width:Number = 0; // I don't know this value!
var height:Number = 0; // I don't know this value!
// Creating and drawing (with transformation)
var result:BitmapData = new BitmapData(width, height, true, 0);
result.draw(origin, matrix);
return result;
}
Some one knows what I should do to find out (calculate) the size of this image after the transformation?
This image illustrates the rotation in action, and what I want to find out:

Ok, using @ansiart answer as starting point I managed to calculate the dimensions this way:
I think that this can be a little overkill, but works.