@Override public void readBytes(IIOByteBuffer buf, int len) throws IOException { src.readBytes(buf, len); }
@Override public void compress(IIOByteBuffer buf, Box2i range) { // TODO Auto-generated method stub throw new UnimplementedException(); }
@Override public void decompress(IIOByteBuffer buf, Box2i range) { // TODO Auto-generated method stub throw new UnimplementedException(); }
@Override public void compress(IIOByteBuffer buf, Box2i range) { throw new UnimplementedException("Unimplemented codec"); }
@Override public void decompress(IIOByteBuffer buf, Box2i range) { throw new UnimplementedException("Unimplemented codec"); }
@Override public void compress(IIOByteBuffer buf, Box2i range) { try { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); DeflaterOutputStream inf = new DeflaterOutputStream(bytes); int n = buf.getLength(); byte[] data = buf.getData(); byte[] pred = new byte[n]; int t1 = 0; int t2 = (n + 1) / 2; int s = buf.getOffset(); int stop = s + n; while (true) { if (s < stop) { pred[t1++] = data[s++]; } else { break; } if (s < stop) { pred[t2++] = data[s++]; } else { break; } } int p = pred[0]; for (int i = 1; i < n; i++) { int d = (int) pred[i] - p + (128 + 256); p = pred[i]; pred[i] = (byte) d; } inf.write(pred); inf.close(); buf.setData(bytes.toByteArray()); buf.setOffset(0); buf.setLength(bytes.size()); } catch (IOException e) { throw new UnexpectedException(e); } }
@Override public void compress(IIOByteBuffer buf, Box2i range) { /* nothing to do. */ }
@Override public void decompress(IIOByteBuffer buf, Box2i range) { /* nothing to do. */ }
void compress(IIOByteBuffer buf, Box2i range);
void decompress(IIOByteBuffer buf, Box2i range);