public JPEGCodec() { super(new ome.codecs.JPEGCodec()); } }
v2.add((byte) 0xd9); JPEGCodec jpeg = new JPEGCodec(); 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);
public void add(byte[] pixels, int x, int y, int w, int h) throws CodecException, IOException { toCompress.add(pixels); 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 = 1; options.bitsPerSample = 8; options.signed = false; byte[] compressed = codec.compress(toCompress.toByteArray(), options); compressedTiles.put(r, compressed); toCompress.clear(); } }
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; } }
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; } }
public JPEGCodec() { super(new ome.codecs.JPEGCodec()); } }