ImageSnapshot类说明
这个类位于mx.graphics包中,提供了一个非常实用的静态函数captureBitmapData函数
这个函数的第一个参数为source:IBitmapDrawable 也就是说,所有可视控件都可以作为这个函数的参数。其他参数都有默认值,如果需要的话可以进行设置。返回值是BitmapData类型的。可以直接获得作为参数传入的控件的截图。
二.ImageSnapshot的使用例子。
下面是一个ImageSnapshot类直接调用captureBitmapData函数获得画面截图的使用例子。
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/To9m/archive/2009/11/03/4764203.aspx
?
<?xml version="1.0" encoding="utf-8"?>?
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">? ??? <mx:Script>? ??????? <!--[CDATA[?? ??????????? import mx.graphics.ImageSnapshot;?? ??????????? private function test():void?? ??????????? {?? ??????????????? var bmp:BitmapData = ImageSnapshot.captureBitmapData(panel);?? ??????????????? img.source = new Bitmap(bmp);?? ??????????? }?? ??????? ]]-->? ??? </mx:Script>? ??? <mx:Image id="img" x="73" y="260" width="531" height="220"/>? ??? <mx:Button x="73" y="488" label="截图" click="test()"/>? ??? <mx:Panel id="panel" x="73" y="34" width="456" height="218" layout="absolute">? ??????? <mx:DataGrid id="dg" x="10" y="10">? ??????????? <mx:columns>? ??????????????? <mx:DataGridColumn headerText="Column 1" dataField="col1"/>? ??????????????? <mx:DataGridColumn headerText="Column 2" dataField="col2"/>? ??????????????? <mx:DataGridColumn headerText="Column 3" dataField="col3"/>? ??????????? </mx:columns>? ??????? </mx:DataGrid>? ??? </mx:Panel>? </mx:Application>?