http://makyoo.cn/article/ActionScript3/11.htm
flash ActionScript3.0 的能力越来越强了 可以做图像像素处理了
经常要做的像素图像的水平、垂直翻转操作 总结出来一个操作类以后用着方便
程序代码 程序代码
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;
}
}
}
[本日志由 makyoo 于 2008-02-16 04:36 PM 编辑]
flash ActionScript3.0 的能力越来越强了 可以做图像像素处理了
经常要做的像素图像的水平、垂直翻转操作 总结出来一个操作类以后用着方便
程序代码 程序代码
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;
}
}
}
[本日志由 makyoo 于 2008-02-16 04:36 PM 编辑]