Examples of ImageReadException


Examples of org.apache.sanselan.ImageReadException

        switch (compression)
        {
            case 1 : // None;
                return compressed;
            case 2 : // CCITT Group 3 1-Dimensional Modified Huffman run-length encoding.
                throw new ImageReadException("Tiff: unknown compression: "
                        + compression);
            case TIFF_COMPRESSION_LZW : // LZW
            {
                InputStream is = new ByteArrayInputStream(compressed);

                int LZWMinimumCodeSize = 8;

                MyLZWDecompressor myLzwDecompressor = new MyLZWDecompressor(
                        LZWMinimumCodeSize, BYTE_ORDER_NETWORK);

                myLzwDecompressor.setTiffLZWMode();

                byte[] result = myLzwDecompressor.decompress(is, expected_size);

                return result;
            }

            case TIFF_COMPRESSION_PACKBITS : // Packbits
            {
                byte unpacked[] = new PackBits().decompress(compressed,
                        expected_size);
                count++;

                return unpacked;
            }

            default :
                throw new ImageReadException("Tiff: unknown compression: "
                        + compression);
        }
    }
View Full Code Here

Examples of org.apache.sanselan.ImageReadException

      params.remove(PARAM_KEY_VERBOSE);

    if (params.size() > 0)
    {
      Object firstKey = params.keySet().iterator().next();
      throw new ImageReadException("Unknown parameter: " + firstKey);
    }

    IcnsContents contents = readImage(byteSource);
    ArrayList images = IcnsDecoder.decodeAllImages(contents.icnsElements);
    if (images.isEmpty())
      throw new ImageReadException("No icons in ICNS file");
    BufferedImage image0 = (BufferedImage) images.get(0);
    return new ImageInfo("Icns", 32, new ArrayList(), ImageFormat.IMAGE_FORMAT_ICNS,
        "ICNS Apple Icon Image", image0.getHeight(), "image/x-icns", images.size(),
        0, 0, 0, 0, image0.getWidth(), false, true, false, ImageInfo.COLOR_TYPE_RGB,
        ImageInfo.COMPRESSION_ALGORITHM_UNKNOWN);
View Full Code Here

Examples of org.apache.sanselan.ImageReadException

      params.remove(PARAM_KEY_VERBOSE);

    if (params.size() > 0)
    {
      Object firstKey = params.keySet().iterator().next();
      throw new ImageReadException("Unknown parameter: " + firstKey);
    }

    IcnsContents contents = readImage(byteSource);
    ArrayList images = IcnsDecoder.decodeAllImages(contents.icnsElements);
    if (images.isEmpty())
      throw new ImageReadException("No icons in ICNS file");
    BufferedImage image0 = (BufferedImage) images.get(0);
    return new Dimension(image0.getWidth(), image0.getHeight());
  }
View Full Code Here

Examples of org.apache.sanselan.ImageReadException

  {
    int Magic = read4Bytes("Magic", is, "Not a Valid ICNS File");
    int FileSize = read4Bytes("FileSize", is, "Not a Valid ICNS File");

    if (Magic != ICNS_MAGIC)
      throw new ImageReadException("Not a Valid ICNS File: " +
          "magic is 0x" + Integer.toHexString(Magic));

    return new IcnsHeader(Magic, FileSize);
  }
View Full Code Here

Examples of org.apache.sanselan.ImageReadException

    IcnsContents icnsContents = readImage(byteSource);
    ArrayList result = IcnsDecoder.decodeAllImages(icnsContents.icnsElements);
    if (result.size() > 0)
      return (BufferedImage) result.get(0);
    else
      throw new ImageReadException("No icons in ICNS file");
  }
View Full Code Here

Examples of org.apache.sanselan.ImageReadException

        TiffField widthField = directory.findField(TIFF_TAG_IMAGE_WIDTH, true);
        TiffField heightField = directory
                .findField(TIFF_TAG_IMAGE_LENGTH, true);

        if ((widthField == null) || (heightField == null))
            throw new ImageReadException("TIFF image missing size info.");

        int height = heightField.getIntValue();
        int width = widthField.getIntValue();

        // -------------------
View Full Code Here

Examples of org.apache.sanselan.ImageReadException

            // segment data is UTF-8 encoded xml.
            String xml = new String(bytes, "utf-8");
            return xml;
        } catch (UnsupportedEncodingException e)
        {
            throw new ImageReadException("Invalid JPEG XMP Segment.");
        }
    }
View Full Code Here

Examples of org.apache.sanselan.ImageReadException

        TiffContents contents = new TiffReader(isStrict(params))
                .readFirstDirectory(byteSource, params, true, formatCompliance);
        TiffDirectory directory = (TiffDirectory) contents.directories.get(0);
        BufferedImage result = directory.getTiffImage(params);
        if (null == result)
            throw new ImageReadException("TIFF does not contain an image.");
        return result;
    }
View Full Code Here

Examples of org.apache.sanselan.ImageReadException

            throws ImageReadException, IOException
    {
        ArrayList entries = directory.entries;

        if (entries == null)
            throw new ImageReadException("TIFF missing entries");

        int photometricInterpretation = directory.findField(
                TIFF_TAG_PHOTOMETRIC_INTERPRETATION, true).getIntValue();
        int compression = directory.findField(TIFF_TAG_COMPRESSION, true)
                .getIntValue();
        int width = directory.findField(TIFF_TAG_IMAGE_WIDTH, true)
                .getIntValue();
        int height = directory.findField(TIFF_TAG_IMAGE_LENGTH, true)
                .getIntValue();
        int samplesPerPixel = directory.findField(TIFF_TAG_SAMPLES_PER_PIXEL,
                true).getIntValue();
        int bitsPerSample[] = directory.findField(TIFF_TAG_BITS_PER_SAMPLE,
                true).getIntArrayValue();
        // TODO: why are we using bits per sample twice? because one is a sum.
        int bitsPerPixel = directory.findField(TIFF_TAG_BITS_PER_SAMPLE, true)
                .getIntValueOrArraySum();

        // int bitsPerPixel = getTagAsValueOrArraySum(entries,
        // TIFF_TAG_BITS_PER_SAMPLE);

        int predictor = -1;
        {
            // dumpOptionalNumberTag(entries, TIFF_TAG_FILL_ORDER);
            // dumpOptionalNumberTag(entries, TIFF_TAG_FREE_BYTE_COUNTS);
            // dumpOptionalNumberTag(entries, TIFF_TAG_FREE_OFFSETS);
            // dumpOptionalNumberTag(entries, TIFF_TAG_ORIENTATION);
            // dumpOptionalNumberTag(entries, TIFF_TAG_PLANAR_CONFIGURATION);
            TiffField predictorField = directory.findField(TIFF_TAG_PREDICTOR);
            if (null != predictorField)
                predictor = predictorField.getIntValueOrArraySum();
        }

        if (samplesPerPixel != bitsPerSample.length)
            throw new ImageReadException("Tiff: samplesPerPixel ("
                    + samplesPerPixel + ")!=fBitsPerSample.length ("
                    + bitsPerSample.length + ")");

        boolean hasAlpha = false;
        BufferedImage result = getBufferedImageFactory(params)
View Full Code Here

Examples of org.apache.sanselan.ImageReadException

        {
            data = bfp.read2Bytes("Pixel", is, "BMP Image Data");
            bytecount += 2;
        }
        else
            throw new ImageReadException("Unknown BitsPerPixel: "
                    + bhi.bitsPerPixel);

        int red = (redMask & data);
        int green = (greenMask & data);
        int blue = (blueMask & 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.