flash player_flash as 3.0实现在线切图效果

时间:2015-07-07  来源:组件控件开发  阅读:
最近在做东西的时候要用到图像的裁剪,自然就要用到bitmapData了。很早以前做过基于透明像素的橡皮檫,这个图像裁剪的原理和橡皮檫的原理一样。也许很久没用又出于陌生了,所以决定好好在做一次,又加深些印象。哈哈...

(双击上面那个心生成图像)
Access" />

以下是图像裁剪核心的代码:
function cutLayer_doubleClick_handler(me:MouseEvent)

cutBtn.mouseEnabled=true;
isCut=false 
itf.actionExit(); //缩放编辑对象退出动作

//temp_bmd主要用于copyPixels ()时候alphaBitmapData的获得,简单理解就是遮照层不规则图象获得
var temp_bmd:BitmapData=new BitmapData(org_sprite.width,org_sprite.height,true,0)
//compare_bmd主要是从源bitmapData在遮照层(不规则图象)上复制的象素图象
var compare_bmd:BitmapData=new BitmapData(org_sprite.width,org_sprite.height,true,0)

//画遮照层对图象的位移,缩放,旋转设置
var temp_matrix:Matrix=new Matrix();

temp_matrix.scale(cut_layer.scaleX,cut_layer.scaleY); 
temp_matrix.rotate(cut_layer.rotation/180*Math.PI);
temp_matrix.translate(cut_layer.x,cut_layer.y); 

//因为遮照层采用了一个遮照Mc和一个透明图象,如果copyPixels时不将alphaBitmapData的透明度为最大.那么copy的图象和alphaBitmapData的透明度是一样的
var temp_ctf:ColorTransform=new ColorTransform()
temp_ctf.alphaOffset=255

//画不规则遮照层
temp_bmd.draw(cut_layer,temp_matrix,temp_ctf);

//复制象素
compare_bmd.copyPixels(org_bmd,
org_sprite.getBounds(this),
new Point(0,0),
temp_bmd,
new Point(0,0),
false);

//显现复制图象
compare_bm.bitmapData=compare_bmd;
}

flash player_flash as 3.0实现在线切图效果

http://m.bbyears.com/asp/16386.html

推荐访问:flash插件 flashfxp flash控件 flash动画制作 flashftp flashget flash动画
相关阅读 猜你喜欢
本类排行 本类最新