我正在尝试拍摄图像的蒙版区域的快照...所以,我加载我的图像然后执行以下功能:
private function manageLoadedImage(e:Event):void
{
_bitdata = e.currentTarget.content; // get the bitmap
_bithold.addChild( _bitdata ); // add the bitmap to a sprite on the stage
_bithold.x = holder1.x -((_bithold.width - holder1.width)/2); // center image
_bithold.y = holder1.y -((_bithold.height - holder1.height)/2); // center image
var m:Shape = new Shape(); // create the shape
m.graphics.beginFill(0x0); // make the fill
m.graphics.drawRect( this.x, this.y, holder1.width, holder1.height ); // draw the mask
m.graphics.endFill(); // end the fill
_bithold.mask = m; // mask the image
}// private function manageNewPaneAddition(e:Event):void
public function save( ):void
{
// WHAT DO I DO HERE ????????
_bmdsrc = new BitmapData( holder1.width, holder1.height ); // create the new bitmapdata
var m:Matrix = _bithold.transform.matrix; // lets try this out
m.tx = -holder1.x + _bithold.width; // not sure what this means ?
m.ty = -holder1.y + _bithold.height; // what does this mean ?
_bmdsrc.draw( _bithold, m); // draw the bitmapdata
// END PROBLEM ??????????????
}// private function save( ):void
因此,在我管理加载的图像后,我保存它。但保存功能仅输出白色方块80x80px。这告诉我,我正在快照一个空白阶段。
MovieClip结构如下:
我有一部电影,在那部电影中我有一个缩略图编辑器名称ThumbEdit。
ThumbEdit在其舞台上有一个名为“holder1”的动画片段。在ThumbEdit的文档类中,我创建了一个精灵“_bithold”并将它放在holder1.x和holder1.y的舞台上。加载图像时,我将图像添加到_bithold,然后使用形状屏蔽_bithold。所以,我想抓一个_bithold蒙面区域的快照,但我不知道该怎么办呢......有什么建议吗?
答案 0 :(得分:2)
有一些方法可以实现您的需求。最简单的是将BitmapData与Matrix classe一起使用,就像你已经完成的那样。
保存方法似乎是正确的,除了引用,可能是coords不正确。考虑到_mask是掩盖内容的形状,你的保存方法应如下所示,_bithold是蒙面动画片段:
public function save( ):void
{
_bmp = new BitmapData( _mask.width, _mask.height ); // creates the bitmap of the mask's size
var m:Matrix = new Matrix();
m.translate( -_mask.x, -_mask.y ); // Create the matrix used to translate the positions of the source image.
_bmp.draw( _bithold, m); // draw the bitmapdata considering the offset of the mask
addChild( new Bitmap(_bmp) ); // just attaching the result on the screen, to see the result.
}
重要的是要注意,翻译矩阵对象的行必须输入相对于_bithold movieclip的值。这意味着如果蒙版形状和蒙版对象(_bithold)不在同一个父对象中,则需要使用globalToLocal和localToGlobal方法将coords带到movieclip父对象。
还有其他疑问,我会在这里!
干杯, CaioToOn!
答案 1 :(得分:1)
您可以尝试使用BitmapData.copyPixels()。
答案 2 :(得分:0)
我决定改用图书馆动画片段。我在舞台上的MovieClip中创建了一个带有蒙版动画片段的框架,其大小我需要。
所以,在舞台上我有一个名为“Snap”的movieclip。内部按扣是两层,面具和支架,都是Movieclips。
当位图加载时,我将它添加到持有者movieclip,它被掩码层适当地屏蔽。然后,我拍摄了“Snap”动画片段的快照。
我可能已经以编程方式对其进行了整理,但这要快得多且非常简单。