位图数据截断
我正在编写一个 MovieClip 光栅化器,它对指定影片剪辑中的所有帧进行光栅化。这是光栅化的代码:
for ( var i:int = start; i <= end; i++ )
{
//goto the next frame
clip.gotoAndStop( i );
//获取边界
边界=clip.getBounds(clip);
//创建一个新的位图数据容器
位图数据 = 新位图数据(
变压器宽度 == -1 ?边界.宽度:变压器.宽度,
变压器高度 == -1 ?边界.高度:变压器.高度,
变压器.透明,
变压器颜色
);
if (transformer.matrix.tx == 0 &&transformer.matrix.ty == 0)transformer.translateToZero(bounds);
//用变压器绘制位图数据
位图数据.draw(
这个._来源,
变压器矩阵,
变压器.colorTransform,
变压器.blendMode,
Transformer.clipRect, //new 矩形(0, 0,bounds.width,bounds.height),
变压器平滑
);
//将数据压入数组
帧.push(位图数据);
}
现在结果不同了 - http://i42.tinypic.com/lfv52.jpg -黑色的是光栅化版本(我使用了颜色变换来测试它:P)。注意头部和左鞋。有人知道问题是什么吗?我见过人们在 BitmapData 构造函数中向边界框添加“额外”像素,但这是正确的解决方案。
有人知道如何很好地融入角色吗?
I am writing a MovieClip rasterizer which rasterizes all the frames in the specified movieclip. Here's the code for rasterizing:
for ( var i:int = start; i <= end; i++ ) { //goto the next frame clip.gotoAndStop( i );//get the bounds bounds = clip.getBounds(clip);
//create a new bitmapdata container bitmapData = new BitmapData( transformer.width == -1 ? bounds.width : transformer.width, transformer.height == -1 ? bounds.height : transformer.height, transformer.transparent, transformer.color );
if (transformer.matrix.tx == 0 && transformer.matrix.ty == 0) transformer.translateToZero( bounds );
//draw the bitmap data with the transformers bitmapData.draw( this._source, transformer.matrix, transformer.colorTransform, transformer.blendMode, transformer.clipRect, //new Rectangle(0, 0, bounds.width, bounds.height), transformer.smoothing );
//push the data on the array frames.push( bitmapData ); }
Now the result is different - http://i42.tinypic.com/lfv52.jpg - the black one is the rasterized version ( i used a color transform on it to test it :P). Note the head and left shoe. Anyone knows what the problem is? I've seen people adding 'extra' pixels to their boundary box at the BitmapData constructor, but thats the right solution.
Anyone got an idea how to fit in the character nicely?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有说 transformer.translateToZero() 的作用,但是您确定字符始终在 (0, 0) 对齐吗?
我的意思是,如果您希望它复制整个MovieClip,您应该将bounds作为BitmapData.draw()的clipRect参数传递。
You didn't say what transformer.translateToZero() does but, are you sure the character is always aligned at (0, 0)?
I mean, you should pass bounds as BitmapData.draw()'s clipRect argument if you wanted it to copy the whole MovieClip.