Package org.apache.sanselan

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


      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

  {
    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

    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

        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

            // 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

        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

            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

        {
            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

                    .getIntArrayValue();

            int expected_colormap_size = 3 * (1 << bitsPerPixel);

            if (colorMap.length != expected_colormap_size)
                throw new ImageReadException("Tiff: fColorMap.length ("
                        + colorMap.length + ")!=expected_colormap_size ("
                        + expected_colormap_size + ")");

            return new PhotometricInterpreterPalette(samplesPerPixel,
                    bitsPerSample, predictor, width, height, colorMap);
        }
        case 2: // RGB
            return new PhotometricInterpreterRGB(samplesPerPixel,
                    bitsPerSample, predictor, width, height);
        case 5: // CMYK
            return new PhotometricInterpreterCMYK(samplesPerPixel,
                    bitsPerSample, predictor, width, height);
        case 6: //
        {
            double yCbCrCoefficients[] = directory.findField(
                    TIFF_TAG_YCBCR_COEFFICIENTS, true).getDoubleArrayValue();

            int yCbCrPositioning[] = directory.findField(
                    TIFF_TAG_YCBCR_POSITIONING, true).getIntArrayValue();
            int yCbCrSubSampling[] = directory.findField(
                    TIFF_TAG_YCBCR_SUB_SAMPLING, true).getIntArrayValue();

            double referenceBlackWhite[] = directory.findField(
                    TIFF_TAG_REFERENCE_BLACK_WHITE, true).getDoubleArrayValue();

            return new PhotometricInterpreterYCbCr(yCbCrCoefficients,
                    yCbCrPositioning, yCbCrSubSampling, referenceBlackWhite,
                    samplesPerPixel, bitsPerSample, predictor, width, height);
        }

        case 8:
            return new PhotometricInterpreterCIELAB(samplesPerPixel,
                    bitsPerSample, predictor, width, height);

        case 32844:
        case 32845: {
            boolean yonly = (photometricInterpretation == 32844);
            return new PhotometricInterpreterLogLUV(samplesPerPixel,
                    bitsPerSample, predictor, width, height, yonly);
        }

        default:
            throw new ImageReadException(
                    "TIFF: Unknown fPhotometricInterpretation: "
                            + photometricInterpretation);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.sanselan.ImageReadException

Copyright © 2018 www.massapicom. 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.