bitmap,bitmapdata截图

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"

fontFamily="宋体" fontSize="12" width="831" height="448">

<mx:Panel id="source" x="26" y="77" width="320" height="263" layout="absolute">

<mx:TextInput x="91" y="51"/>

<mx:TextInput x="91" y="106"/>

<mx:Button x="73.5" y="158" label="取  消"/>

<mx:Button x="172.5" y="158" label="确  定"/>

<mx:Label x="32" y="53" text="用户名:"/>

<mx:Label x="32" y="108" text="密  码:"/>

<mx:Label x="109" y="10" text="用户登录" fontWeight="bold"/>

</mx:Panel>

<mx:Canvas id="showImage" x="427" y="58" width="347" height="292">

</mx:Canvas>

<mx:Label x="124" y="32" text="截图区域"/>

<mx:Label x="562" y="32" text="截图显示区域"/>

<mx:Button x="147" y="394" label="截图" click="onClick()"/>

<mx:Button x="548" y="394" label="显示" click="onShow()"/>

<mx:Script>

<![CDATA[

import mx.core.UIComponent;

private var bmpImage:Bitmap = null;

private function onClick():void

{

//创建一个大小和截图对象一致的图片

var bmpData:BitmapData = new BitmapData(source.width,source.height);

//进行快照截图,其中第二个参数Matrix是对图片进行变换用的,例如旋转缩放等。

//如果图片不需要变换可以用new Matrix()或者null都可以。

bmpData.draw(source,new Matrix());

//创建Bitmap对象

bmpImage = new Bitmap(bmpData);

}

private function onShow():void

{

//创建一个UIComponent对象

var uic:UIComponent = new UIComponent();

//将Bitmap对象加入到UIComponent对象中

uic.addChild(bmpImage);

//将UIComponent对象加入Canvas中

showImage.addChild(uic);

}

]]>

</mx:Script>

</mx:Application>

你可能感兴趣的:(xml,Adobe)