Package org.apache.sanselan.common

Examples of org.apache.sanselan.common.BinaryFileParser.readByte()


        InputStream is = new ByteArrayInputStream(segmentData);

        // Skip precision(1 Byte), height(2 Bytes), width(2 bytes) bytes.
        if (toBeProcessed > 6) {
          binaryParser.skipBytes(is, 5, INVALID_JPEG_ERROR_MSG);
          numComponents = binaryParser.readByte("Number_of_components", is,
              "Unable to read Number of components from SOF marker");
          toBeProcessed -= 6;
        } else {
          LOG.log(Level.WARNING, "Failed to SOF marker");
          return;
View Full Code Here


        // TODO(satya): Extend this library to gray scale images.
        if (numComponents == 3 && toBeProcessed == 9) {
          // Process 'Luma' Channel.
          // Skipping the component Id field.
          binaryParser.skipBytes(is, 1, INVALID_JPEG_ERROR_MSG);
          imageParams.setSamplingMode(binaryParser.readByte("Sampling Factors", is,
              "Unable to read the sampling factor from the 'Y' channel component spec"));
          imageParams.setLumaIndex(binaryParser.readByte("Quantization Table Index", is,
              "Unable to read Quantization table index of 'Y' channel"));

          // Process 'Chroma' Channel.
View Full Code Here

          // Process 'Luma' Channel.
          // Skipping the component Id field.
          binaryParser.skipBytes(is, 1, INVALID_JPEG_ERROR_MSG);
          imageParams.setSamplingMode(binaryParser.readByte("Sampling Factors", is,
              "Unable to read the sampling factor from the 'Y' channel component spec"));
          imageParams.setLumaIndex(binaryParser.readByte("Quantization Table Index", is,
              "Unable to read Quantization table index of 'Y' channel"));

          // Process 'Chroma' Channel.
          // Skipping the component Id and sampling factor fields.
          binaryParser.skipBytes(is, 2, INVALID_JPEG_ERROR_MSG);
View Full Code Here

              "Unable to read Quantization table index of 'Y' channel"));

          // Process 'Chroma' Channel.
          // Skipping the component Id and sampling factor fields.
          binaryParser.skipBytes(is, 2, INVALID_JPEG_ERROR_MSG);
          imageParams.setChromaIndex(binaryParser.readByte("Quantization Table Index", is,
              "Unable to read Quantization table index of 'Cb' Channel"));
        } else {
          LOG.log(Level.WARNING, "Failed to Component Spec from SOF marker");
        }
      }
View Full Code Here

      private void parseQuantizationTables(int markerLength, byte[] segmentData)
          throws ImageReadException, IOException {
        InputStream is = new ByteArrayInputStream(segmentData);
        int toBeProcessed = markerLength - 2;
        while (toBeProcessed > 1) {
          int tableInfo = binaryParser.readByte("Quantization Table Info", is,
                                                "Not able to read Quantization Table Info");
          toBeProcessed--;
          int tableIndex = tableInfo & 0x0f;
          int precision = tableInfo >> 4;
          if (toBeProcessed < 64*(precision + 1)) {
View Full Code Here

          }

          int[] quanTable = new int[64];
          for (int i = 0; i < 64; i++) {
            quanTable[i] = (precision == 0) ?
                binaryParser.readByte("Reading", is, "Reading Quanization Table Failed") :
                binaryParser.read2Bytes("Reading", is, "Reading Quantization Table Failed");
          }
          imageParams.addQTable(tableIndex, quanTable);
          toBeProcessed -= 64*(precision + 1);
        }
View Full Code Here

        InputStream is = new ByteArrayInputStream(segmentData);

        int toBeProcessed = markerLength -2;
        while (toBeProcessed > 1) {
          // Reading the table info byte.
          int tableInfo = binaryParser.readByte("Huffman Table Info", is,
                                                "Not able to read Huffman Table Info");
          toBeProcessed--;

          // Reading the counts of symbols from length 1...16.
          if (toBeProcessed < 16) {
View Full Code Here

          if (toBeProcessed < 16) {
            return;
          }
          int numSymbols =0;
          for (int i = 0; i < 16; i++) {
            numSymbols += binaryParser.readByte("Num symbols", is,
                                                "Not able to read num symbols");
          }
          toBeProcessed -= 16 + numSymbols;

          // It is highly unlikely that a huffman optimized image has same number of
View Full Code Here

        InputStream is = new ByteArrayInputStream(segmentData);

        // Skip precision(1 Byte), height(2 Bytes), width(2 bytes) bytes.
        if (toBeProcessed > 6) {
          binaryParser.skipBytes(is, 5, INVALID_JPEG_ERROR_MSG);
          numComponents = binaryParser.readByte("Number_of_components", is,
              "Unable to read Number of components from SOF marker");
          toBeProcessed -= 6;
        } else {
          LOG.log(Level.WARNING, "Failed to SOF marker");
          return;
View Full Code Here

        // TODO(satya): Extend this library to gray scale images.
        if (numComponents == 3 && toBeProcessed == 9) {
          // Process 'Luma' Channel.
          // Skipping the component Id field.
          binaryParser.skipBytes(is, 1, INVALID_JPEG_ERROR_MSG);
          imageParams.setSamplingMode(binaryParser.readByte("Sampling Factors", is,
              "Unable to read the sampling factor from the 'Y' channel component spec"));
          imageParams.setLumaIndex(binaryParser.readByte("Quantization Table Index", is,
              "Unable to read Quantization table index of 'Y' channel"));

          // Process 'Chroma' Channel.
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.