Examples of writeBits()


Examples of com.peterhi.runtime.BitStream.writeBits()

  }
 
  @Test
  public void testToByteArray() throws Exception {
    BitStream bs = new BitStream(2);
    bs.writeBits(BigInteger.valueOf(255), 8);
    bs.writeBits(BigInteger.valueOf(255), 8);
    byte[] data = bs.toByteArray();
    assertEquals(-1, data[0]);
    assertEquals(-1, data[1]);
    bs.readBits(4, true);
View Full Code Here

Examples of com.peterhi.runtime.BitStream.writeBits()

 
  @Test
  public void testToByteArray() throws Exception {
    BitStream bs = new BitStream(2);
    bs.writeBits(BigInteger.valueOf(255), 8);
    bs.writeBits(BigInteger.valueOf(255), 8);
    byte[] data = bs.toByteArray();
    assertEquals(-1, data[0]);
    assertEquals(-1, data[1]);
    bs.readBits(4, true);
    data = bs.toByteArray();
View Full Code Here

Examples of javax.imageio.stream.MemoryCacheImageOutputStream.writeBits()

        ArrayList<byte[]> codeTable = createCodeTable();
        int chunk = 9;

        byte[] inputPattern = null;
        MemoryCacheImageOutputStream out = new MemoryCacheImageOutputStream(encoded);
        out.writeBits(CLEAR_TABLE, chunk);
        int foundCode = -1;
        int r;
        while ((r = rawData.read()) != -1)
        {
            byte by = (byte) r;
View Full Code Here

Examples of javax.imageio.stream.MemoryCacheImageOutputStream.writeBits()

                int newFoundCode = findPatternCode(codeTable, inputPattern);
                if (newFoundCode == -1)
                {
                    // use previous
                    chunk = calculateChunk(codeTable.size() - 1, 1);
                    out.writeBits(foundCode, chunk);
                    // create new table entry
                    codeTable.add(inputPattern);

                    if (codeTable.size() == 4096)
                    {
View Full Code Here

Examples of javax.imageio.stream.MemoryCacheImageOutputStream.writeBits()

                    codeTable.add(inputPattern);

                    if (codeTable.size() == 4096)
                    {
                        // code table is full
                        out.writeBits(CLEAR_TABLE, chunk);
                        chunk = 9;
                        codeTable = createCodeTable();
                    }

                    inputPattern = new byte[]
View Full Code Here

Examples of javax.imageio.stream.MemoryCacheImageOutputStream.writeBits()

            }
        }
        if (foundCode != -1)
        {
            chunk = calculateChunk(codeTable.size() - 1, 1);
            out.writeBits(foundCode, chunk);
        }

        // PPDFBOX-1977: the decoder wouldn't know that the encoder would output
        // an EOD as code, so he would have increased his own code table and
        // possibly adjusted the chunk. Therefore, the encoder must behave as
View Full Code Here

Examples of javax.imageio.stream.MemoryCacheImageOutputStream.writeBits()

        // possibly adjusted the chunk. Therefore, the encoder must behave as
        // if the code table had just grown and thus it must be checked it is
        // needed to adjust the chunk, based on an increased table size parameter
        chunk = calculateChunk(codeTable.size(), 1);

        out.writeBits(EOD, chunk);
        out.writeBits(0, 7); // pad with 0
        out.flush(); // must do or file will be empty :-(
    }

    /**
 
View Full Code Here

Examples of javax.imageio.stream.MemoryCacheImageOutputStream.writeBits()

        // if the code table had just grown and thus it must be checked it is
        // needed to adjust the chunk, based on an increased table size parameter
        chunk = calculateChunk(codeTable.size(), 1);

        out.writeBits(EOD, chunk);
        out.writeBits(0, 7); // pad with 0
        out.flush(); // must do or file will be empty :-(
    }

    /**
     * Find the longest matching pattern in the code table.
View Full Code Here

Examples of javax.imageio.stream.MemoryCacheImageOutputStream.writeBits()

            deviceColorSpace = PDDeviceGray.INSTANCE;
            for (int y = 0; y < height; ++y)
            {
                for (int x = 0; x < width; ++x)
                {
                    mcios.writeBits(image.getRGB(x, y) & 0xFF, bpc);
                }
                while (mcios.getBitOffset() != 0)
                {
                    mcios.writeBit(0);
                }
View Full Code Here

Examples of javax.imageio.stream.MemoryCacheImageOutputStream.writeBits()

        ArrayList<byte[]> codeTable = createCodeTable();
        int chunk = 9;

        byte[] inputPattern = null;
        MemoryCacheImageOutputStream out = new MemoryCacheImageOutputStream(result);
        out.writeBits(CLEAR_TABLE, chunk);
        int foundCode = -1;
        int r;
        while ((r = rawData.read()) != -1)
        {
            byte by = (byte) r;
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.