位图数据截断

发布于 2024-08-25 00:28:20 字数 936 浏览 4 评论 0原文

我正在编写一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放赐 2024-09-01 00:28:20

您没有说 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文