代码翻转bitmap图。水平翻转,垂直翻转。

来源:互联网 发布:windows wmi 监控进程 编辑:程序博客网 时间:2024/05/01 19:17
package com.makyoo.bitmapchange{ //www.makyoo.cn    makyoo    QQ:84407979
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    public class Bitmapchange extends Sprite {
         //上下翻转
        public static function upanddown(bt:BitmapData):BitmapData {
            var bmd:BitmapData = new BitmapData(bt.width, bt.height, true, 0x00000000);
            for (var xx=0; xx<bt.width; xx++) {
                for (var yy=0; yy<bt.height; yy++) {
                    bmd.setPixel32(xx, bt.height-yy-1, bt.getPixel32(xx,yy));
                }
            }
            return bmd;
        }
        //左右翻转
        public static function rightandleft(bt:BitmapData):BitmapData {
            var bmd:BitmapData = new BitmapData(bt.width, bt.height, true, 0x00000000);
            for (var yy=0; yy<bt.height; yy++) {
                for (var xx=0; xx<bt.width; xx++) {
                    bmd.setPixel32(bt.width-xx-1, yy, bt.getPixel32(xx,yy));
                }
            }
            return bmd;
        }
    }
}
原创粉丝点击