Perhaps you could read just the palette info from the image file instead of
looping through the bitmapdata to gather that data. That could be more or
less challenging depending on the file format of the image.

Cheers
Juan Pablo Califano


2008/2/27, EECOLOR <[EMAIL PROTECTED]>:
>
> 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

Reply via email to