开发者

How to scale around point using BitmapData

I've searched but haven't found anyone wanting to do this with a bitmapData object.

I'm using the following code:

matrix.identity();
matrix.transl开发者_开发百科ate(pan.x, pan.y);
matrix.translate(-zoomPoint.x, -zoomPoint.y);
matrix.scale(scale, scale);
matrix.translate(zoomPoint.x, zoomPoint.y);

// later my draw call
this.bitmapData.draw(srcBitmap, matrix, null, null, null, true);

pan is a Point containing translation values scale contains 0..1 zoomPoint is a Point containing a mouse click

Panning works, but using this method scale does not scale around my mouse. Has anyone done this successfully?

Thanks.


The matrix will translate the scale first, so you might have to take that into account when you set the translation. I needed to scale and select an area previously, and came up with this: BitmapData - scale and select area in one matrix?


This Works:

var scale:Number = 0.32;

var matrix:Matrix = new Matrix();

matrix.scale(scale, scale);

var smallBMD:BitmapData = new BitmapData(bigBMD.width * scale, bigBMD.height * scale, true, 0x000000);

smallBMD.draw(bigBMD, matrix, null, null, null, true);

var bitmap:Bitmap = new Bitmap(smallBMD, PixelSnapping.NEVER, true);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜