BitmapData.draw

public function draw(containerisplayObjectContainer,targetisplayObject,w:Number=150,h:Number=200):BitmapData
{
	var rect:Rectangle = target.getBounds(target);
	var scale:Number = getScale(w,h);
	var vw:Number = (w - target.width * scale) / 2;
	var vh:Number = (h - target.height * scale) / 2;
	this.samllMapBMD = new BitmapData(w,h,true,0);
	var matrix:Matrix = new Matrix  ;
	matrix.tx -=  rect.topLeft.x;
	matrix.ty -=  rect.topLeft.y;
	matrix.scale(scale,scale);
	matrix.scale(target.scaleX,target.scaleY);
	matrix.tx +=  vw;
	matrix.ty +=  vh;
	var rect2:Rectangle = new Rectangle(0,0,w,h);
	var bitmapdata:Bitmapdata = new Bitmapdata(rect2.width,rect2.height,true,0);
	bitmapdata.draw(target,matrix,null,null,rect2);
	return bitmapdata;
}
public function getScale(w:Number,h:Number):Number
{

	var size:Number;
	var scale:Number;
	var num:Number = this.width - this.height;
	var num2:Number = w - h;
	num2 < 0 ? size = w:size = h;
	num > 0 ? scale = size / this.width:scale = size / this.height;
	return scale;

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值