public byte[] get(int x, int y, int w, int h) throws CodecException, IOException { Region[] keys = compressedTiles.keySet().toArray(new Region[0]); Region r = new Region(x, y, w, h); for (Region key : keys) { if (key.intersects(r)) { r = key; } } if (!r.equals(lastRegion)) { lastRegion = r; byte[] compressed = null; compressed = compressedTiles.get(r); if (compressed == null) return null; lastTile = codec.decompress(compressed, options); } int pixel = options.channels * (options.bitsPerSample / 8); byte[] buf = new byte[w * h * pixel]; for (int i=0; i<h; i++) { System.arraycopy(lastTile, r.width * pixel * (i + y - r.y) + (x - r.x), buf, i * w * pixel, pixel * w); } return buf; } }
byte[] top = jpeg.decompress(v.toByteArray(), options); byte[] bottom = jpeg.decompress(v2.toByteArray(), options); v.add((byte) 0xff); v.add((byte) 0xd9); return new JPEGCodec().decompress(v.toByteArray(), options);