【问题标题】:Flash/AS3 - MovieClip into BitmapFlash/AS3 - 影片剪辑成位图
【发布时间】:2015-07-23 13:45:08
【问题描述】:

我需要将舞台上的影片剪辑转换为位图。我为此做了一半的功能;它确实使用正确的图像从 MovieClip 制作位图,但不会旋转它。

这里是函数

    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;
}

这是输出

我应该如何旋转位图,或者只复制该位图中的所有像素,旋转和全部?

【问题讨论】:

  • 您找到解决方案了吗?跟进 cmets / answers 是很好的,这样未来的访问者就知道什么对你有用,什么没用。

标签: actionscript-3 bitmap rotation


【解决方案1】:

你检查过rotate() 函数和fl.motion.MatrixTransformer 类吗? this 的问题看起来也很有帮助。

【讨论】:

  • 感谢您的建议。我现在使用的是 Matrix 类,而不是 MatrixTransformer,因为这是绘制函数所需要的。但是,现在出现了一个新问题,当我旋转 bitmapData 时,它会将边缘剪掉。那么如何阻止它被剪辑呢?
  • 由于 Flash 使用矩形作为主要形状,因此在边缘和角落相交的点处裁剪了旋转的形状。我不确定,但您可以将位图放在一个大矩形容器中,以便它以全尺寸显示。
  • 考虑通过提供示例来使您的答案更有用,而不仅仅是建议和链接 - 现在这更适合问题而不是真正的答案。
  • 所以你的意思是如果某人没有足够的代表来“评论别人的帖子”,他们就不应该帮助他们吗?您没有按时间顺序排列事件。
【解决方案2】:

在实现您的代码的函数中。

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

【讨论】:

    【解决方案3】:

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

    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;
    }
    

    【讨论】:

      猜你喜欢
      • 2013-09-29
      • 2018-03-29
      • 1970-01-01
      • 2012-06-07
      • 2011-11-02
      • 1970-01-01
      • 1970-01-01
      • 2011-08-29
      • 2014-09-25
      相关资源
      最近更新 更多