如何使用 BitmapData 围绕点缩放
我已经搜索过,但没有发现有人想要使用 bitmapData 对象执行此操作。
我使用以下代码:
matrix.identity();
matrix.translate(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 是包含翻译值的 Point 标度包含 0..1 ZoomPoint 是一个包含鼠标单击的点
平移可以工作,但使用此方法缩放不会围绕我的鼠标缩放。有人成功做到这一点吗?
谢谢。
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.translate(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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
矩阵将首先平移比例,因此在设置平移时可能必须考虑到这一点。我之前需要缩放并选择一个区域,并想出了这个: BitmapData - 在一个矩阵中缩放并选择区域?
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?
这是可行的:
var scale:Number = 0.32;
var 矩阵:Matrix = new Matrix();
矩阵.scale(比例,比例);
var SmallBMD:BitmapData = new BitmapData(bigBMD.width * 比例尺, bigBMD.height * 比例尺, true, 0x000000);
SmallBMD.draw(bigBMD, 矩阵, null, null, null, true);
var bitmap:Bitmap = new Bitmap(smallBMD, PixelSnapping.NEVER, true);
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);