I need to port a bit of ActionScript code into Java. btw, never touched a as
file in my life.
So far it's been easy, because AS syntax is fairly simple. There's a piece of code that calls
bmpData.paletteMap( bmpData , rect, point, rArray, gArray, bArray); //all arrays of size 256
The entire file is kind of dependent on this function and it is kind of alien to me, i need to understand what it actually does so that i can write my own implementation of paletteMap
.
I don't need the code, just an explanation of the procedure. If it's already been done, that's even better.
edit: Here's what i make of the algorithm, is it correct?
private static void paletteMap(int[] rgbStream,int [] r,int[] g,int []b)
{
if(r == null || g == null || b == null)
throw new NullPointerException("Array can't null array.");
for(int i = 0 ; i < rgbStream.length; i++)
{
int pixel = rgbStream[i], newPixel = 0;
newPixel = b[pixel & 0xFF]; pixel >>= 8;
newPixel |= g[pixel & 0xFF] << 8; pixel >>= 8;
newPixel |= r[pixel & 0xFF] << 16;
rgbStream[i] = newPixel;
}
}
Thanks.