How can I change the bitmapdata of a coloured Bitmap to Black and White in AS3 ? I\'m developing a simple image editor tool for a CMS in f
Well, just using getPixel and setPixel, and averaging the colors (I'm sure there may be another way to do this with a filter or something):
for(int i = 0; i < bitmapData.height; i++)
{
for(int j = 0; j < bitmapData.width; j++)
{
var color:uint = bitmapData.getPixel(i, j);
var red:uint = color & 0xFF0000 >> 16;
var green:uint = color & 0x00FF00 >> 8;
var blue:uint = color & 0x0000FF >> 0;
var bwColor:uitn = red + green + blue / 3;
bwColor = bwColor << 16 + bwColor << 8 + bwColor; // puts the average in each channel
bitmapData.setPixel(i, j, bwColor);
}
}