自定义滤镜 ColorMatrixFilter
var url:URLRequest = new URLRequest("Koala.jpg"); var l:Loader = new Loader(); l.contentLoaderInfo.addEventListener(Event.COMPLETE,function():void{ exe(); }); l.load(url); function exe():void{ var d:Bitmap = l.content as Bitmap; addChild(d); var ar:Array = [// RedPassage GreenPassage BluePassage PassageAlpha RedPassageOffset 1,0,0,0,0, //RedCount * Val0 ReadCount*Val1 RedCount*Val2 RedAlpha*Val -+ 255 RGBVal 0,1,0,0,0, //GreenCount*Val0 GreenCount*Val1 GreenCount*Val2 GreenAlpha*Val -+ 255 RGBVal 0,0,1,0,0, //BC -1,0,0,1,0 //RedColorAlpha*Val GCA*Val BCA*Val RCBCA*Val ... ]; var cf:ColorMatrixFilter = new ColorMatrixFilter(ar); d.filters = [cf]; }
//这里对颜色的所有操作 都是相对于像素点的值 0xARGB 来做的
如 1,0,0,0,10 RED
0x00 10 00 00
最后计算为 10*1+10