BitmapData()建構函式
public function BitmapData(width:int, height:int, transparent:Boolean = true, fillColor:uint = 0xFFFFFFFF)
copyChannel()方法
public function copyChannel(sourceBitmapData:BitmapData, sourceRect:Rectangle, destPoint:Point, sourceChannel:uint, destChannel:uint):void
991211_BitmapData.copyChannel_2.swf
import flash.display.Loader; import flash.net.URLRequest; import flash.events.Event; import flash.events.ProgressEvent; import flash.display.BitmapData; import flash.text.TextField; import flash.text.TextFormat; import flash.geom.Rectangle; import flash.geom.Point; import flash.display.Bitmap; // const bmURL:String = "991211_photo_1.jpg"; var ldr:Loader = new Loader(); ldr.load(new URLRequest(bmURL)); ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete); ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress); // var bmData1:BitmapData; //0xffff0000 <---ARGB色彩,A為不透明度. var bmData2:BitmapData = new BitmapData(360, 240, true, 0xffff0000); var bm1:Bitmap; var bm2:Bitmap; // var format:TextFormat = new TextFormat(); with(format){ color = 0xff00ff; size = 88; font = "Lucida Fax"; bold = true; align = "center"; } // var tF:TextField = new TextField; with(tF){ x = 0; y = 150; width = 550; //autoSize = TextFieldAutoSize.LEFT; } tF.defaultTextFormat = format; addChild(tF); // function onProgress(e:ProgressEvent):void{ tF.text = String(Math.floor((e.bytesLoaded/e.bytesTotal*100))); } // var rect:Rectangle = new Rectangle(0,0, 550, 400); var point:Point = new Point(0, 0); // function onLoaderComplete(e:Event):void{ tF.text = ""; gogo(); } //copyChannel()方法 //public function copyChannel(sourceBitmapData:BitmapData, sourceRect:Rectangle, destPoint:Point, sourceChannel:uint, destChannel:uint):void //http://help.adobe.com/zh_TW/Flash/CS5/AS3LR/flash/display/BitmapData.html#copyChannel() function gogo(){ bmData1 = (ldr.content as Bitmap).bitmapData; bmData2.copyChannel(bmData1, rect, point, BitmapDataChannel.RED, BitmapDataChannel.RED); bmData2.copyChannel(bmData1, rect, point, BitmapDataChannel.GREEN, BitmapDataChannel.GREEN); bmData2.copyChannel(bmData1, rect, point, BitmapDataChannel.BLUE, BitmapDataChannel.BLUE); //bm1 = new Bitmap(bmData1); bm2 = new Bitmap(bmData2); bm2.x = 60; bm2.y = 60; //addChild(bm1); addChild(bm2); }
991211_BitmapData.copyChannel_2a.swf - 拷貝紅藍兩個色版色版
沒有留言:
張貼留言