# BitmapData and Transformation Matrices?

**URL:** <https://forum.kirupa.com/t/bitmapdata-and-transformation-matrices/214481>\
**Category:** flash\
**Created:** [January 29, 2007, 12:42pm UTC](https://forum.kirupa.com/t/bitmapdata-and-transformation-matrices/214481 "2007-01-29T12:42:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![duncanhall](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@duncanhall](https://forum.kirupa.com/u/duncanhall)\
**Post date:** [January 29, 2007, 12:42pm UTC](https://forum.kirupa.com/t/bitmapdata-and-transformation-matrices/214481/1 "2007-01-29T12:42:36Z")

</div>

I’ve started getting to grips with using the BitmapData class and a Transformation Matrix in the hope that I can start making some interesting image effects. However, at the moment Im having trouble figuring out how to shift the newly created bitmap so that any scale transformations are applied from the center rather than the top left corner.

See here for example: [http://www.duncanhall.net/tmatrix.html](http://www.duncanhall.net/tmatrix.html)

The flower on the left is the original, the flower on the right is the new image created using “bitmapData.draw()”. It has been scaled up to twice the size, but I want this to happen from the center of the image.

[AS]  
import flash.display.BitmapData;  
import flash.geom.Matrix;  
/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
VARS  
_**/  
var the\_bmp:BitmapData = new BitmapData(flower\_mc.\_width, flower\_mc.\_height, false, 0x00FFFFFF);  
var m:Matrix = new Matrix(1, 0, 0, 1, 0, 0);  
m.scale(2,2);  
/**_  
RUN  
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/  
the\_bmp.draw(flower\_mc, m);  
this.createEmptyMovieClip(“holder\_mc”, 10);  
holder\_mc.attachBitmap(the\_bmp, 10);  
holder\_mc.\_x = 300;  
holder\_mc.\_y = 75;  
[/AS]

If anyone can help me on this I’d most appreciate it.
