actionscript-3 - 将 AS3 中的位图数据旋转 180 度以进行导出

标签 actionscript-3 flash matrix bitmap bitmapdata

我在 AS3 flash 中有一个位图,我使用 base64 编码的 jpg 字符串将它发送到 javascript。

所有这些都很好用。我需要将 img 缩小并旋转 180 度。缩放有效,但旋转无效。轮换永远不会发生。我知道我显然做错了,但不知道正确的方法。

所以基本上我只需要将图像旋转 180 度,所以当它被发送到 javascript 时它是颠倒的。

这是我的转换代码

var scaleFactor:int = 5;

var tempBitmap:BitmapData = new BitmapData(img.width/scaleFactor, img.height/scaleFactor);
var drawMatrix:Matrix = new Matrix(1/scaleFactor, 0, 0, 1 /scaleFactor );
drawMatrix.rotate(Math.PI); //180deg

tempBitmap.draw(img, drawMatrix);

最佳答案

我认为你需要在旋转后平移你的对象,否则它会被剪裁,所以你看不到它,我在舞台上使用 CS5 在 MovieClip 中做了一个位图示例。

import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;

var scaleFactor:int = 1;

var tempBitmap:BitmapData = new BitmapData(img.width, img.height);

var rotationMatrix:Matrix = new Matrix();
rotationMatrix.rotate(Math.PI);
rotationMatrix.translate(img.width, img.height);

tempBitmap.draw(box_mc, rotationMatrix);
var output:Bitmap = new Bitmap(tempBitmap);

addChild(output);

我没有搞乱缩放,我想你可以自己做。我放在舞台上的一个在右边,绘制的位图数据在舞台的左上角,并且正确反转。

更新

也看看fl.motion.MatrixTransformer根据下面的 32bitkid 评论!

enter image description here

关于actionscript-3 - 将 AS3 中的位图数据旋转 180 度以进行导出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10813952/

相关文章:

flash - RED5 1.0 录制问题 NetStream.Buffer.Empty

java - 如何运行一个允许传入连接的简单套接字服务器?

python - 如何在python中表示矩阵

image - Matlab:极坐标灰度图

matrix - 了解在 WebGL 中绕任意轴旋转背后的数学原理

java - 发送重力消息时出现错误#2173

actionscript-3 - '@' 在 ActionScript 中有什么作用?

actionscript-3 - TextField() 设置插入符号位置

android - [AS3][Air for Android] 获取流式麦克风输入?

javascript - jquery.flash 插件在 IE6 中不工作