【问题标题】:BitmapData cut-off位图数据截断
【发布时间】:2010-03-13 19:38:32
【问题描述】:

我正在编写一个MovieClip rasterizer,它对指定movieclip 中的所有帧进行光栅化。这是光栅化的代码:

for ( var i:int = start; i <= end; i++ )
{
 //goto the next frame
 clip.gotoAndStop( i );

//获取边界 bounds = clip.getBounds(clip);

//创建一个新的位图数据容器 位图数据 = 新位图数据( 变压器宽度 == -1 ? bounds.width:transformer.width, 变压器.高度 == -1 ? bounds.height :transformer.height, 变压器.透明的, 变压器.color );

if (transformer.matrix.tx == 0 && transformer.matrix.ty == 0)transformer.translateToZero(bounds);

//用转换器绘制位图数据 位图数据.draw( this._source, 变压器.矩阵, 变压器.colorTransform, 变压器.blendMode, transformer.clipRect, //new Rectangle(0, 0, bounds.width, bounds.height), 变压器平滑 );

//将数据推入数组 帧.push(位图数据); }

现在结果不同了 - http://i42.tinypic.com/lfv52.jpg - 黑色的是光栅化版本(我在它上面使用了颜色变换来测试它:P)。注意头部和左鞋。任何人都知道问题是什么?我见过人们在 BitmapData 构造函数中向边界框添加“额外”像素,但这是正确的解决方案。

有人知道如何很好地融入角色吗?

【问题讨论】:

    标签: actionscript-3 bitmapdata rasterizing


    【解决方案1】:

    你没有说 transformer.translateToZero() 做了什么,但是你确定字符总是在 (0, 0) 对齐吗?

    我的意思是,如果你希望它复制整个 MovieClip,你应该将 bounds 作为 BitmapData.draw() 的 clipRect 参数传递.

    【讨论】:

    • translateToZero 这样做:_matrix.translate(-bounds.x, -bounds.y); //_matrix = flash.geom.Matrix 它将动画剪辑的当前 x 和 y 轴反转为零。如果我将边界传递给 BitmapData.draw 方法的 clipRect,则将绘制 1/4 的动画剪辑,因为动画剪辑居中。
    猜你喜欢
    • 2016-02-11
    • 1970-01-01
    • 1970-01-01
    • 2014-08-26
    • 2017-03-24
    • 1970-01-01
    • 2015-08-07
    • 1970-01-01
    • 2015-03-09
    相关资源
    最近更新 更多