Sweet, thanks!

Elia

----- Original Message ----- From: "Juan Pablo Califano" <[EMAIL PROTECTED]>
To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
Sent: Sunday, February 17, 2008 11:59 PM
Subject: Re: [Flashcoders] Swap 8 bit palettes


If I'm not getting this wrong, this simple function should do the work
(assuming you have your palette defined as an array)

I've tested in Flash 8 (that's why I'm using Number's instead of int's; for
AS 3.0 I'd go with int's)


function createPaletteData(palette:Array):Object {
var len:Number  = palette.length;

var r:Array = [];
var g:Array = [];
var b:Array = [];

var cur:Number;

for(var i:Number = 0;i<len;i++) {
 cur  = palette[i];
 r[i] = cur >> 16;
 g[i] = (cur & 0x00ff00) >> 8;
 b[i] = (cur & 0x0000ff);
}

return {r:r,g:g,b:b};
}

var test_arr:Array = [0xff005c,0xfc1236,0x001200,0x180055];

var oArrays:Object = createPaletteData(test_arr);

trace(oArrays.r);
trace(oArrays.g);
trace(oArrays.b);


Cheers
Juan Pablo Califano



2008/2/17, Elia Morling <[EMAIL PROTECTED]>:

Has anyone by any chance made a function to dump an 8 bit palette to the
arrays the paletteMap function is asking for? :)

I guess the alternative is to create an image that holds the palette as
pixels in rows, and then use getpixel to pull one rgb at a time to
populate
the arrays.

Elia

----- Original Message -----
From: "Elia Morling" <[EMAIL PROTECTED]>
To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
Sent: Sunday, February 17, 2008 10:41 PM
Subject: Re: [Flashcoders] Swap 8 bit palettes


> Thanks I will check it out. The images we are talking of are not
> anti-alias.
>
> Elia
>
> ----- Original Message -----
> From: "Zeh Fernando" <[EMAIL PROTECTED]>
> To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
> Sent: Sunday, February 17, 2008 10:10 PM
> Subject: Re: [Flashcoders] Swap 8 bit palettes
>
>
>> You can do a lot of color transformations with the color matrix.
>>
>> If you want to swap the PALLETE, oldschool-style, one color at a time,
>> you just use the paletteMap method of the BitmapData class. It's only
>> really useful if you don't have antialias on your image or else it
>> becomes a monumental task to do anything.
>>
>> Zeh
>>
>> Elia Morling wrote:
>>> Ok m8.
>>>
>>> My artist has 8-bit tile graphics. We want to swap the colors in >>> those
>>> tile graphics by changing the palette.
>>> It's a simple operation really, I just wonder if Flash supports it.
>>>
>>> Cheers
>>> Elia
>>>
>>> ----- Original Message ----- From: "Juan Pablo Califano"
>>> <[EMAIL PROTECTED]>
>>> To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
>>> Sent: Sunday, February 17, 2008 7:31 PM
>>> Subject: Re: [Flashcoders] Swap 8 bit palettes
>>>
>>>
>>>> Perhaps if you describe your problem / what you're trying to do with
a
>>>> little more detail...
>>>>
>>>> 2008/2/17, Elia Morling <[EMAIL PROTECTED]>:
>>>>>
>>>>> I guess not?
>>>>>
>>>>> " Is it possible to swap 8 bit palettes directly in Flash?"
>>>>> _______________________________________________
>>>>> 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
>>> _______________________________________________
>>> 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
_______________________________________________
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
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to