• AS3.0实现图像的扭曲


     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 }
  • 相关阅读:
    LUA之面向对象
    LUA笔记之表
    LUA笔记之字符串
    STM32模拟I2C
    php(1)-php5.6启动命令
    ip地址变更对tomcat和nginx的影响
    解决 nginx: [alert] kill(189, 1) failed (3: No such process)
    linux(16)-yum安装提示“没有可用软件包”
    性能测试监控分析(17) 负载和CPU使用率低高负载的原因
    Codeforces Round #588 (Div. 2)C(思维,暴力)
  • 原文地址:https://www.cnblogs.com/ebel/p/2508940.html
Copyright © 2020-2023  润新知