Flash / AS3 - MovieClip到Bitmap

时间:2015-07-23 13:45:08

标签: actionscript-3 bitmap rotation

我需要将舞台上的MovieClip变成Bitmap。我为这个中途所做的功能;它确实使用正确的图像从MovieClip创建一个Bitmap,但它不会旋转它。

这是函数

    function makeBitmapData(mov):BitmapData
{
    var bmpData:BitmapData = new BitmapData(mov.width, mov.height, true, 0);
    bmpData.draw(mov);
    this.addChild(new Bitmap(bmpData)); //Shows the bitmap on screen purely for example
    return bmpData;
}

这是输出

Not rotating

我应该如何旋转位图,或者只是纯粹复制该位图中的所有像素,旋转所有像素?

3 个答案:

答案 0 :(得分:0)

您检查过rotate()函数和fl.motion.MatrixTransformer类吗? this问题也很有用。

答案 1 :(得分:0)

在实现代码的函数中。

    var b:Bitmap = new Bitmap (  makeBitmapData(mov) );
    addChild(b);
    b.rotation = mov.rotation;

答案 2 :(得分:0)

实现此目的的一种方法是从父项中绘制,这样任何转换/过滤器​​都将反映在捕获的位图数据中。所以像这样:

function makeBitmapData(mov:DisplayObject):BitmapData
{
    var rect:Rectangle = mov.getBounds(mov.parent); //get the bounds of the item relative to it's parent
    var bmpData:BitmapData = new BitmapData(rect.width, rect.height, false, 0xFF0000);
    //you have to pass a matrix so you only draw the part of the parent that contains the child.
    bmpData.draw(mov.parent, new Matrix(1,0,0,1,-rect.x,-rect.y));
    addChild(new Bitmap(bmpData)); //Shows the bitmap on screen purely for example
    return bmpData;
}
相关问题