flash as3 加载图片变黑白滤镜

package{
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.filters.*;
import fl.motion.AdjustColor;
public class LoadImg extends MovieClip {
var filterBW:Array;//黑白色滤镜
function LoadImg()
{
//变为灰白特效
var adjustColor:AdjustColor = new AdjustColor();//高级调色板
adjustColor.brightness = 20; //亮度
adjustColor.contrast = 20; //对比度
adjustColor.hue = 0; //色调
adjustColor.saturation = -100; //饱合度
var matrix:Array = adjustColor.CalculateFinalFlatArray();
var colorMatrix:ColorMatrixFilter = new ColorMatrixFilter(matrix);
filterBW = [colorMatrix];
//画板
var imgSprite:Sprite = new Sprite();
//加载器
var imgLoader:Loader = new Loader();
imgLoader.load(new URLRequest("d:/1.png"));
imgSprite.addChild(imgLoader);
//像素流
var bigmapData:BitmapData = new BitmapData(96,96);
bigmapData.draw(imgSprite);
var bigmap:Bitmap = new Bitmap(bigmapData);
addChild(imgSprite);
//为画板添加滤镜
imgSprite.filters = filterBW;
//imgSprite.filters = [];
}
}
}

 

来源:http://www.qingruxu.com/code/flash/794.html

你可能感兴趣的:(图片,Flash,as3,黑白)