int[] pixels = new int[w * h];
img.getRGB(0, 0, w, h, pixels, 0, w);
// quantize image
QuantizeFilter qf = new QuantizeFilter();
bitmap = new Bitmap(img.getWidth(), img.getHeight());
int ct[] = qf.quantize(pixels, bitmap.getInternalBuffer(), w, h, 255, false, false);
int size = ct.length;
if (size > 255) {
logger.warn("Quantizer failed.\n");
size = 255;
}