首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用BitmapData的操作

使用BitmapData的操作
EN

Stack Overflow用户
提问于 2011-04-20 11:39:21
回答 2查看 643关注 0票数 0

我们有一个正方形的电影剪辑,上面有一些平淡的电影剪辑。考虑一个斜角的斜角。我想用电影剪辑的bimap数据进行以下转换:位于上面的三角形然后对角线保持不变,下三角形应该用上三角形的尺寸反射代替。

是否有一种简单的方法来做到这一点?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-04-20 13:56:43

确切地说,方法是拍摄电影的快照,然后镜像,再拍另一张快照,并将这两个快照组合在一起。请注意,您将获得的内容将是“静态的”,因此这样您就不能复制电影的动画部分。

代码语言:javascript
运行
复制
//store the movie's graphical content in a bitmapdata
var bmd:BitmapData = new BitmapData(movie.width, movie.height);
bmd.draw(movie);

//then create a temporary movie in which you will do the mirroring
var temp:MovieClip = new MovieClip();
temp.addChild(new Bitmap(bmd));

//create the diagonal mask
var _mask:MovieClip = new MovieClip();
with(_mask.graphics) beginFill(0xff0000), lineTo(movie.width, 0), lineTo(movie.width, movie.height), lineTo(0, 0), endFill();
temp.addChild(_mask);
temp.mask = _mask;
//this is the mirroring part
temp.scaleX = temp.scaleY = -1;
addChild(temp);

//then create another bitmapdata for storing the so called "upper-triangle"
//important, that this bitmapdata should be transparent, "true" sets this
var bmd1:BitmapData = new BitmapData(temp.width, temp.height, true, 0x00);
//then do another mirroring transformation
var matrix:Matrix = new Matrix(-1, 0, 0, -1);
matrix.tx = temp.width;
matrix.ty = temp.height;
//draw the visual content on the bitmapdata
bmd1.draw(temp, matrix);

//and finally, on the original bitmapdata, draw the mirrored part
bmd.draw(bmd1);

//and add it to the top layer of the original movie, or whatever you want to do with it
movie.addChild(new Bitmap(bmd));
票数 2
EN

Stack Overflow用户

发布于 2011-04-20 13:40:39

我能想到的最简单的方法是旋转电影45,把上面的矩形反画成下矩形,然后将位图旋转回45。您可以使用矩阵( BitmapData.draw方法中的第二个参数)来绘制旋转的矩阵,而不是实际地旋转任何东西。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5729589

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档