Reputation: 815
Let´s say I have a bitmap with 3 colors: red, green and blue (not mixed)
What if I wanted to make a bitmap of the red part of the first bitmap?
I´d like to take the red pixels from first bitmap (and its positions), and make another bitmap.
Is that possible?
Upvotes: 0
Views: 133
Reputation: 2786
As and addition to solution posted by shanethehat, I will point you to this amazing class called - colormatrix, written by SO user quasimondo. It gives you more efficient way to work with channels in the action script. And if you are going to work with bitmap and graphics in general you can checkout the Quasimondo Libs from google code repository.
Upvotes: 2
Reputation: 15580
You can use BitmapData.copyChannel()
to copy a single channel's color information into a new BitmapData object.
Something like this (untested):
//myBitmap is the source bitmap
var oldBMD:BitmapData = myBitmap.bitmapData;
var newBMD:BitmapData = new BitmapData(oldBMD.width,oldBMD.height,true,0);
oldBmd.copyChannel(newBMD, null, null, BitmapDataChannel.RED, BitmapDataChannel.RED);
var newBitmap:Bitmap = new Bitmap(newBMD);
Upvotes: 3