public void add(byte[] array) { add(array, 0, array.length); }
public void add(byte x) { this.vector.add(x); }
public void add(byte[] array) { this.vector.add(array); }
public void add(byte[] array, int off, int len) { this.vector.add(array, off, len); }
public void add(byte x) { this.vector.add(x); }
public void add(byte[] array) { this.vector.add(array); }
public void add(byte[] array, int off, int len) { this.vector.add(array, off, len); }
(byte) ((b3) >> 6 ^ 0xfc); encoded.add(lookupBase64Alphabet[v1]); encoded.add(lookupBase64Alphabet[v2 | (k << 4)]); encoded.add(lookupBase64Alphabet[(l << 2) | v3]); encoded.add(lookupBase64Alphabet[b3 & 0x3f]); byte v = ((b1 & -128) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0); encoded.add(lookupBase64Alphabet[v]); encoded.add(lookupBase64Alphabet[k << 4]); encoded.add(PAD); encoded.add(PAD); (byte) ((b2) >> 4 ^ 0xf0); encoded.add(lookupBase64Alphabet[v1]); encoded.add(lookupBase64Alphabet[v2 | (k << 4)]); encoded.add(lookupBase64Alphabet[l << 2]); encoded.add(PAD);
@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(); }
decodedData.add((byte) (b1 << 2 | b2 >> 4)); if (p >= nRead && in.getFilePointer() >= in.length()) break; if (marker0 != PAD && marker1 != PAD) { b4 = base64Alphabet[marker1]; decodedData.add((byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf))); decodedData.add((byte) (b3 << 6 | b4)); decodedData.add((byte) 0); decodedData.add((byte) 0); decodedData.add((byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf))); decodedData.add((byte) 0);
b.add((byte) raw[i]); if (raw[i] == (byte) 0xff) { b.add((byte) 0); ByteVector b2 = new ByteVector(); for (int i=0; i<raw2.length; i++) { b2.add((byte) raw2[i]); if (raw2[i] == (byte) 0xff) { b2.add((byte) 0); v.add(HEADER); v.add(new byte[] {(byte) 0xff, (byte) 0xdb}); v.add((byte) ((length >>> 8) & 0xff)); v.add((byte) (length & 0xff)); v.add((byte) 0); v.add(quant); v.add((byte) 1); v.add(quant2 == null ? quant : quant2); v.add(new byte[] {(byte) 0xff, (byte) 0xc4}); length = 2; for (Table t : huffmanTables) { v.add((byte) ((length >>> 8) & 0xff)); v.add((byte) (length & 0xff));
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; } }