我在 AS3 flash 中有一个位图,我使用 base64 编码的 jpg 字符串将其发送到 javascript。
一切都很好。我需要发送按比例缩小并旋转 180 度的 img。缩放有效,但旋转无效。轮换永远不会发生。我知道我显然做错了,但不知道正确的方法。
所以基本上我只需要将图像旋转 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);
我没有搞乱缩放,我想你可以自己做。我放在舞台上的那个位于右侧,绘制的位图数据位于舞台的左上方,并且正确反转。
UPDATE
还可以看看fl.motion.MatrixTransformer http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/motion/MatrixTransformer.html#rotateAroundExternalPoint%28%29根据下面 32bitkid 的评论!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)