import flash.display.BitmapData; /** * 将图像的Alpha通道转换为黑白图像 */ var p:Point = new Point(0,0); var bmpd:BitmapData = new ImagePNG();//绑定的png图片 var channelBmpd:BitmapData = new BitmapData(bmpd.width,bmpd.height,true,0x00000000); channelBmpd.fillRect(bmpd.rect, 0xff000000); channelBmpd.copyChannel(bmpd, bmpd.rect, p, 8, 1); channelBmpd.copyChannel(bmpd, bmpd.rect, p, 8, 2); channelBmpd.copyChannel(bmpd, bmpd.rect, p, 8, 4); var bmp = new Bitmap(channelBmpd); this.addChild(bmp);