1 import flash.display.Sprite; 2 import flash.display.Loader; 3 import flash.net.URLRequest; 4 import flash.events.Event; 5 import flash.display.Bitmap; 6 import flash.display.BitmapData; 7 8 var pixelsArr : Array; 9 var loader : Loader; 10 var url : String; 11 var bitMap : Bitmap; 12 var outPut : Bitmap; 13 var outPutData : BitmapData; 14 15 init("imag.jpg"); 16 17 function draw(source:BitmapData, w:Number, h:Number, topLen:Number ):BitmapData 18 { 19 outPutData=new BitmapData(1024,768,true, 0x000000); 20 var tanA : Number=(h - topLen) / w; 21 var tmpHeight:Number; 22 for (var i:uint=0; i < w; i++) 23 { 24 tmpHeight = topLen + i*tanA; 25 for (var k:uint=0; k < tmpHeight; k++) 26 { 27 outPutData.setPixel32(i, k + (h - tmpHeight) / 2, source.getPixel32(i*(source.width/w), k*(source.height / tmpHeight))); 28 } 29 } 30 return outPutData; 31 } 32 33 function init(strURL:String):void 34 { 35 loader = new Loader(); 36 loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onPicLoaded); 37 loader.load(new URLRequest(strURL)); 38 39 } 40 41 function onPicLoaded(evt : Event):void 42 { 43 addChild(loader); 44 loader.x = 10 45 loader.y = 10 46 loader.width=300; 47 loader.height=200; 48 49 pixelsArr = new Array(); 50 var $loader : Loader = Loader(evt.target.loader); 51 bitMap = Bitmap($loader.content); 52 var $bitmapData: BitmapData = bitMap.bitmapData; 53 outPut = new Bitmap(draw($bitmapData, 200, 500, 160)); 54 outPut.y = 100; 55 outPut.x = 310 56 addChild(outPut); 57 }