public void add(int[] pixels, int x, int y, int w, int h)
throws CodecException, IOException
{
byte[] buf = new byte[pixels.length * 3];
for (int i=0; i<pixels.length; i++) {
buf[i * 3] = (byte) ((pixels[i] & 0xff0000) >> 16);
buf[i * 3 + 1] = (byte) ((pixels[i] & 0xff00) >> 8);
buf[i * 3 + 2] = (byte) (pixels[i] & 0xff);
}
toCompress.add(buf);
row++;
if ((y % ROW_COUNT) == ROW_COUNT - 1 || y == getHeight() - 1 ||
y == yy + hh - 1)
{
Region r = new Region(x, y - row + 1, w, row);
options.width = w;
options.height = row;
options.channels = 3;
options.bitsPerSample = 8;
options.signed = false;
byte[] compressed = codec.compress(toCompress.toByteArray(), options);
compressedTiles.put(r, compressed);
toCompress.clear();
row = 0;
}
}