Examples of Inflater


Examples of java.util.zip.Inflater

    public static byte[] processDeflateEncoded(byte[] compressed, int sizeLimit) throws IOException {
        ByteArrayOutputStream outStream = new ByteArrayOutputStream(EXPECTED_DEFLATE_COMPRESSION_RATIO * compressed.length);

        // "true" because HTTP does not provide zlib headers
        Inflater inflater = new Inflater(true);
        InflaterInputStream inStream = new InflaterInputStream(new ByteArrayInputStream(compressed), inflater);

        byte[] buf = new byte[BUF_SIZE];
        int written = 0;
        while (true) {
View Full Code Here

Examples of java.util.zip.Inflater

        switch (ze.getMethod()) {
            case ZipEntry.STORED:
                return bis;
            case ZipEntry.DEFLATED:
                bis.addDummy();
                final Inflater inflater = new Inflater(true);
                return new InflaterInputStream(bis, inflater) {
                    @Override
                    public void close() throws IOException {
                        super.close();
                        inflater.end();
                    }
                };
            default:
                throw new ZipException("Found unsupported compression method "
                                       + ze.getMethod());
View Full Code Here

Examples of java.util.zip.Inflater

        switch (ze.getMethod()) {
            case ZipEntry.STORED:
                return bis;
            case ZipEntry.DEFLATED:
                bis.addDummy();
                final Inflater inflater = new Inflater(true);
                return new InflaterInputStream(bis, inflater) {
                    @Override
                    public void close() throws IOException {
                        super.close();
                        inflater.end();
                    }
                };
            default:
                throw new ZipException("Found unsupported compression method "
                                       + ze.getMethod());
View Full Code Here

Examples of java.util.zip.Inflater

    return "B1";
  }

  protected byte[] decompress(byte input[], int len) {
    int olen = 0;
    Inflater decompresser = new Inflater();
    byte output[] = new byte[len];
    decompresser.setInput(input);
    try {
      olen = decompresser.inflate(output);
    } catch(java.util.zip.DataFormatException e) {
    }
    decompresser.end();
    if(len != olen) return new byte[0];
    return output;
  }
View Full Code Here

Examples of java.util.zip.Inflater

    }
    // Is it compressed?
    if((firstByte & 1) == 1) {
      try {
        // Gzipped
        Inflater i = new Inflater();
        i.setInput(data, offset, length);
        // We shouldn't ever need a 4096 bytes long ref!
        byte[] output = new byte[4096];
        length = i.inflate(output, 0, output.length);
        // Finished
        data = output;
        offset = 0;
        if(logMINOR)
          Logger.minor(PeerNode.class, "We have decompressed a "+length+" bytes big reference.");
View Full Code Here

Examples of java.util.zip.Inflater

    private void decode(ByteBuffer buffer, int stride, boolean flip) throws IOException {
        final int offset = buffer.position();
        byte[] curLine = new byte[width*bytesPerPixel+1];
        byte[] prevLine = new byte[width*bytesPerPixel+1];
       
        final Inflater inflater = new Inflater();
        try {
            for(int yIndex=0 ; yIndex<height ; yIndex++) {
              int y = yIndex;
              if (flip) {
                y = height - 1 - yIndex;
              }
             
                readChunkUnzip(inflater, curLine, 0, curLine.length);
                unfilter(curLine, prevLine);

                buffer.position(offset + y*stride);

                switch (colorType) {
                case COLOR_TRUECOLOR:
                case COLOR_TRUEALPHA:
                  copy(buffer, curLine);
                  break;
                case COLOR_INDEXED:
                  copyExpand(buffer, curLine);
                  break;
                default:
                    throw new UnsupportedOperationException("Not yet implemented");
                }

                byte[] tmp = curLine;
                curLine = prevLine;
                prevLine = tmp;
            }
        } finally {
            inflater.end();
        }
       
        bitDepth = hasAlpha() ? 32 : 24;
    }
View Full Code Here

Examples of java.util.zip.Inflater

  private final ByteBuffer outBuffer;
  private int inflaterPos = 0;
  private int decompressedLength;

  public InflaterDataAccess(DataAccess dataAccess, long offset, int compressedLength) {
    this(dataAccess, offset, compressedLength, -1, new Inflater(), new byte[512], null);
  }
View Full Code Here

Examples of java.util.zip.Inflater

  public InflaterDataAccess(DataAccess dataAccess, long offset, int compressedLength) {
    this(dataAccess, offset, compressedLength, -1, new Inflater(), new byte[512], null);
  }

  public InflaterDataAccess(DataAccess dataAccess, long offset, int compressedLength, int actualLength) {
    this(dataAccess, offset, compressedLength, actualLength, new Inflater(), new byte[512], null);
  }
View Full Code Here

Examples of java.util.zip.Inflater

        if (compressedLen == 0) {
          data = null;
          dataOffset = dataLen = 0;
        } else {
          if (data[0] == 0x78 /* 'x' */) {
            Inflater zlib = new Inflater();
            zlib.setInput(data, 0, compressedLen);
            byte[] result = new byte[actualLen * 3];
            int resultLen = zlib.inflate(result);
            zlib.end();
            data = result;
            dataOffset = 0;
            dataLen = resultLen;
          } else if (data[0] == 0x75 /* 'u' */) {
            dataOffset = 1;
View Full Code Here

Examples of java.util.zip.Inflater

    }

    public static byte[] decompress(byte[] compressedData, int off, int len) throws IOException, DataFormatException
    {
       // Create the decompressor and give it the data to compress
        Inflater decompressor = new Inflater();
        decompressor.setInput(compressedData, off, len);

        // Create an expandable byte array to hold the decompressed data
        ByteArrayOutputStream bos = new ByteArrayOutputStream(compressedData.length);

        // Decompress the data
        byte[] buf = new byte[1024];
        while (!decompressor.finished())
        {
            int count = decompressor.inflate(buf);
            bos.write(buf, 0, count);
        }
        bos.close();

        // Get the decompressed data
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.