// better
// choice
// here.
bos.write(LZWMinimumCodeSize);
MyLZWCompressor compressor = new MyLZWCompressor(
LZWMinimumCodeSize, BYTE_ORDER_LSB, false); // GIF
// Mode);
byte imagedata[] = new byte[width * height];
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
int argb = src.getRGB(x, y);
int rgb = 0xffffff & argb;
int index;
if (hasAlpha)
{
int alpha = 0xff & (argb >> 24);
final int alphaThreshold = 255;
if (alpha < alphaThreshold)
index = palette2.length(); // is transparent
else
index = palette2.getPaletteIndex(rgb);
} else
{
index = palette2.getPaletteIndex(rgb);
}
imagedata[y * width + x] = (byte) index;
}
}
byte compressed[] = compressor.compress(imagedata);
writeAsSubBlocks(bos, compressed);
image_data_total += compressed.length;
}
// palette2.dump();