public byte[] toByteArray() { return this.vector.toByteArray(); }
public byte[] toByteArray() { return this.vector.toByteArray(); }
@Override public byte[] compress(byte[] data, CodecOptions options) throws CodecException { if (data == null || data.length == 0) throw new IllegalArgumentException("No data to compress"); Deflater deflater = new Deflater(); deflater.setInput(data); deflater.finish(); byte[] buf = new byte[8192]; ByteVector bytes = new ByteVector(); int r = 0; // compress until eof reached while ((r = deflater.deflate(buf, 0, buf.length)) > 0) { bytes.add(buf, 0, r); } return bytes.toByteArray(); }
@Override public byte[] decompress(RandomAccessInputStream in, CodecOptions options) throws CodecException, IOException { InflaterInputStream i = new InflaterInputStream(in); ByteVector bytes = new ByteVector(); byte[] buf = new byte[8192]; int r = 0; // read until eof reached try { while ((r = i.read(buf, 0, buf.length)) > 0) bytes.add(buf, 0, r); } catch (EOFException e) { } return bytes.toByteArray(); }
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 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; } }
b2 = base64Alphabet[block[p++]]; return decodedData.toByteArray();
toDecode = b.toByteArray();
return encoded.toByteArray();
v2.add(v.toByteArray()); v.add(b.toByteArray()); v.add((byte) 0xff); v.add((byte) 0xd9); v2.add(b2.toByteArray()); v2.add((byte) 0xff); v2.add((byte) 0xd9); byte[] top = jpeg.decompress(v.toByteArray(), options); byte[] bottom = jpeg.decompress(v2.toByteArray(), options); v.add(b.toByteArray()); v.add((byte) 0xff); v.add((byte) 0xd9); return new JPEGCodec().decompress(v.toByteArray(), options);
return dst.toByteArray(); return dst.toByteArray();