Thanks Erik for looking into this. I don't understand how anyone can use the
paletteMap method without knowing what order the colors in the palette are
in? Are the colors always in the order as your loop? In photoshop a palette
can be arranged in any way.
Elia
----- Original Message -----
From: "EECOLOR" <[EMAIL PROTECTED]>
To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
Sent: Wednesday, February 27, 2008 10:47 PM
Subject: Re: [Flashcoders] BitmapData.paletteMap ()
So if I understand you correctly, your question actually is: "how do I
find
out which colors are used in my bitmap data?".
I am sorry to disappoint you, but I do not have an answer for you. The
only
solution I could come up with is looping through the pixels (see the code
at
the end of the email). This loop however is too slow. On my fast machine
it
took about 2.4 seconds for an image of 2000 x 2000. If time is not an
issue
you could split the loop over multiple frames so you can show a progress
bar.
Maybe someone has a better idea for you...
Greetz Erik
var byteArray:ByteArray = bmd.getPixels(new Rectangle(0, 0, bmd.width,
bmd.height));
var red:Array = new Array();
var green:Array = new Array();
var blue:Array = new Array();
var color:uint;
var redColor:uint;
var greenColor:uint;
var blueColor:uint;
byteArray.position = 0;
while (byteArray.bytesAvailable)
{
color = byteArray.readUnsignedInt();
redColor = (color >> 16) & 0xFF;
greenColor = (color >> 8) & 0xFF;
blueColor = (color) & 0xFF;
if (!red[redColor])
{
red[redColor] = redColor;
};
if (!green[greenColor])
{
green[greenColor] = greenColor;
};
if (!blue[blueColor])
{
blue[blueColor] = blueColor;
};
};
On 2/27/08, Elia Morling <[EMAIL PROTECTED]> wrote:
As indicated in earlier post I need to swap the palettes of a bitmapdata.
"public function paletteMap(sourceBitmapData:BitmapData,
sourceRect:Rectangle, destPoint:Point, redArray:Array = null,
greenArray:Array = null, blueArray:Array = null, alphaArray:Array =
null):void
Remaps the color channel values in an image that has up to four arrays of
color palette data, one for each channel."
That is excellent, but how do I extract the current color channel values
as
arrays so that I can maniuplate them?
Elia
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders