// better
// choice
// here.
bos.write(lzwMinimumCodeSize);
final MyLzwCompressor compressor = new MyLzwCompressor(
lzwMinimumCodeSize, ByteOrder.LITTLE_ENDIAN, false); // GIF
// Mode);
final byte[] imagedata = new byte[width * height];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
final int argb = src.getRGB(x, y);
final int rgb = 0xffffff & argb;
int index;
if (hasAlpha) {
final 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;
}
}
final byte[] compressed = compressor.compress(imagedata);
writeAsSubBlocks(bos, compressed);
// image_data_total += compressed.length;
}
// palette2.dump();