Java Code Examples for java.awt.image.RenderedImage#getSampleModel()

The following examples show how to use java.awt.image.RenderedImage#getSampleModel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GIFImageWriter.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private boolean needToCreateIndex(RenderedImage image) {

        SampleModel sampleModel = image.getSampleModel();
        ColorModel colorModel = image.getColorModel();

        return sampleModel.getNumBands() != 1 ||
            sampleModel.getSampleSize()[0] > 8 ||
            colorModel.getComponentSize()[0] > 8;
    }
 
Example 2
Source File: GIFImageWriter.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private boolean needToCreateIndex(RenderedImage image) {

        SampleModel sampleModel = image.getSampleModel();
        ColorModel colorModel = image.getColorModel();

        return sampleModel.getNumBands() != 1 ||
            sampleModel.getSampleSize()[0] > 8 ||
            colorModel.getComponentSize()[0] > 8;
    }
 
Example 3
Source File: GIFImageWriter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private boolean needToCreateIndex(RenderedImage image) {

        SampleModel sampleModel = image.getSampleModel();
        ColorModel colorModel = image.getColorModel();

        return sampleModel.getNumBands() != 1 ||
            sampleModel.getSampleSize()[0] > 8 ||
            colorModel.getComponentSize()[0] > 8;
    }
 
Example 4
Source File: GIFImageWriter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private boolean needToCreateIndex(RenderedImage image) {

        SampleModel sampleModel = image.getSampleModel();
        ColorModel colorModel = image.getColorModel();

        return sampleModel.getNumBands() != 1 ||
            sampleModel.getSampleSize()[0] > 8 ||
            colorModel.getComponentSize()[0] > 8;
    }
 
Example 5
Source File: GIFImageWriter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private boolean needToCreateIndex(RenderedImage image) {

        SampleModel sampleModel = image.getSampleModel();
        ColorModel colorModel = image.getColorModel();

        return sampleModel.getNumBands() != 1 ||
            sampleModel.getSampleSize()[0] > 8 ||
            colorModel.getComponentSize()[0] > 8;
    }
 
Example 6
Source File: GIFImageWriter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private boolean needToCreateIndex(RenderedImage image) {

        SampleModel sampleModel = image.getSampleModel();
        ColorModel colorModel = image.getColorModel();

        return sampleModel.getNumBands() != 1 ||
            sampleModel.getSampleSize()[0] > 8 ||
            colorModel.getComponentSize()[0] > 8;
    }
 
Example 7
Source File: ImageUtil.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Returns whether the image has contiguous data across rows.
 */
public static final boolean imageIsContiguous(RenderedImage image) {
    SampleModel sm;
    if(image instanceof BufferedImage) {
        WritableRaster ras = ((BufferedImage)image).getRaster();
        sm = ras.getSampleModel();
    } else {
        sm = image.getSampleModel();
    }

    if (sm instanceof ComponentSampleModel) {
        // Ensure image rows samples are stored contiguously
        // in a single bank.
        ComponentSampleModel csm = (ComponentSampleModel)sm;

        if (csm.getPixelStride() != csm.getNumBands()) {
            return false;
        }

        int[] bandOffsets = csm.getBandOffsets();
        for (int i = 0; i < bandOffsets.length; i++) {
            if (bandOffsets[i] != i) {
                return false;
            }
        }

        int[] bankIndices = csm.getBankIndices();
        for (int i = 0; i < bandOffsets.length; i++) {
            if (bankIndices[i] != 0) {
                return false;
            }
        }

        return true;
    }

    // Otherwise true if and only if it's a bilevel image with
    // a MultiPixelPackedSampleModel, 1 bit per pixel, and 1 bit
    // pixel stride.
    return ImageUtil.isBinary(sm);
}
 
Example 8
Source File: ImageUtil.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns whether the image has contiguous data across rows.
 */
public static final boolean imageIsContiguous(RenderedImage image) {
    SampleModel sm;
    if(image instanceof BufferedImage) {
        WritableRaster ras = ((BufferedImage)image).getRaster();
        sm = ras.getSampleModel();
    } else {
        sm = image.getSampleModel();
    }

    if (sm instanceof ComponentSampleModel) {
        // Ensure image rows samples are stored contiguously
        // in a single bank.
        ComponentSampleModel csm = (ComponentSampleModel)sm;

        if (csm.getPixelStride() != csm.getNumBands()) {
            return false;
        }

        int[] bandOffsets = csm.getBandOffsets();
        for (int i = 0; i < bandOffsets.length; i++) {
            if (bandOffsets[i] != i) {
                return false;
            }
        }

        int[] bankIndices = csm.getBankIndices();
        for (int i = 0; i < bandOffsets.length; i++) {
            if (bankIndices[i] != 0) {
                return false;
            }
        }

        return true;
    }

    // Otherwise true if and only if it's a bilevel image with
    // a MultiPixelPackedSampleModel, 1 bit per pixel, and 1 bit
    // pixel stride.
    return ImageUtil.isBinary(sm);
}
 
Example 9
Source File: WarpNearestOpImage.java    From geowave with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a WarpNearestOpImage.
 *
 * @param source The source image.
 * @param config RenderingHints used in calculations.
 * @param layout The destination image layout.
 * @param warp An object defining the warp algorithm.
 * @param interp An object describing the interpolation method.
 * @param roi input ROI object used.
 * @param noData NoData Range object used for checking if NoData are present.
 */
public WarpNearestOpImage(
    final RenderedImage source,
    final Map<?, ?> config,
    final ImageLayout layout,
    final Warp warp,
    final Interpolation interp,
    final ROI sourceROI,
    final Range noData,
    final double[] bkg) {
  super(
      source,
      layout,
      config,
      false,
      null, // extender not needed in
      // nearest-neighbor
      // interpolation
      interp,
      warp,
      bkg,
      sourceROI,
      noData);

  /*
   * If the source has IndexColorModel, override the default setting in OpImage. The dest shall
   * have exactly the same SampleModel and ColorModel as the source. Note, in this case, the
   * source should have an integral data type.
   */
  final ColorModel srcColorModel = source.getColorModel();
  if (srcColorModel instanceof IndexColorModel) {
    sampleModel = source.getSampleModel().createCompatibleSampleModel(tileWidth, tileHeight);
    colorModel = srcColorModel;
  }

  /*
   * Selection of a destinationNoData value for each datatype
   */
  final SampleModel sm = source.getSampleModel();
  // Source image data Type
  final int srcDataType = sm.getDataType();

  // Creation of a lookuptable containing the values to use for no data
  if ((srcDataType == DataBuffer.TYPE_BYTE) && hasNoData) {
    final int numBands = getNumBands();
    byteLookupTable = new byte[numBands][256];
    for (int b = 0; b < numBands; b++) {
      for (int i = 0; i < byteLookupTable[0].length; i++) {
        final byte value = (byte) i;
        if (noDataRange.contains(value)) {
          byteLookupTable[b][i] = (byte) backgroundValues[b];
        } else {
          byteLookupTable[b][i] = value;
        }
      }
    }
  }
}
 
Example 10
Source File: ImageUtil.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns whether the image has contiguous data across rows.
 */
public static final boolean imageIsContiguous(RenderedImage image) {
    SampleModel sm;
    if(image instanceof BufferedImage) {
        WritableRaster ras = ((BufferedImage)image).getRaster();
        sm = ras.getSampleModel();
    } else {
        sm = image.getSampleModel();
    }

    if (sm instanceof ComponentSampleModel) {
        // Ensure image rows samples are stored contiguously
        // in a single bank.
        ComponentSampleModel csm = (ComponentSampleModel)sm;

        if (csm.getPixelStride() != csm.getNumBands()) {
            return false;
        }

        int[] bandOffsets = csm.getBandOffsets();
        for (int i = 0; i < bandOffsets.length; i++) {
            if (bandOffsets[i] != i) {
                return false;
            }
        }

        int[] bankIndices = csm.getBankIndices();
        for (int i = 0; i < bandOffsets.length; i++) {
            if (bankIndices[i] != 0) {
                return false;
            }
        }

        return true;
    }

    // Otherwise true if and only if it's a bilevel image with
    // a MultiPixelPackedSampleModel, 1 bit per pixel, and 1 bit
    // pixel stride.
    return ImageUtil.isBinary(sm);
}
 
Example 11
Source File: GIFImageWriter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Writes any extension blocks, the Image Descriptor, and the image data
 *
 * @param iioimage The image and image metadata.
 * @param param The write parameters.
 * @param globalColorTable The Global Color Table.
 * @param sourceBounds The source region.
 * @param destSize The destination dimensions.
 */
private void writeImage(RenderedImage image,
                        GIFWritableImageMetadata imageMetadata,
                        ImageWriteParam param, byte[] globalColorTable,
                        Rectangle sourceBounds, Dimension destSize)
  throws IOException {
    ColorModel colorModel = image.getColorModel();
    SampleModel sampleModel = image.getSampleModel();

    boolean writeGraphicsControlExtension;
    if (imageMetadata == null) {
        // Create default metadata.
        imageMetadata = (GIFWritableImageMetadata)getDefaultImageMetadata(
            new ImageTypeSpecifier(image), param);

        // Set GraphicControlExtension flag only if there is
        // transparency.
        writeGraphicsControlExtension = imageMetadata.transparentColorFlag;
    } else {
        // Check for GraphicControlExtension element.
        NodeList list = null;
        try {
            IIOMetadataNode root = (IIOMetadataNode)
                imageMetadata.getAsTree(IMAGE_METADATA_NAME);
            list = root.getElementsByTagName("GraphicControlExtension");
        } catch(IllegalArgumentException iae) {
            // Should never happen.
        }

        // Set GraphicControlExtension flag if element present.
        writeGraphicsControlExtension =
            list != null && list.getLength() > 0;

        // If progressive mode is not MODE_COPY_FROM_METADATA, ensure
        // the interlacing is set per the ImageWriteParam mode setting.
        if (param != null && param.canWriteProgressive()) {
            if (param.getProgressiveMode() ==
                ImageWriteParam.MODE_DISABLED) {
                imageMetadata.interlaceFlag = false;
            } else if (param.getProgressiveMode() ==
                       ImageWriteParam.MODE_DEFAULT) {
                imageMetadata.interlaceFlag = true;
            }
        }
    }

    // Unset local color table if equal to global color table.
    if (Arrays.equals(globalColorTable, imageMetadata.localColorTable)) {
        imageMetadata.localColorTable = null;
    }

    // Override dimensions
    imageMetadata.imageWidth = destSize.width;
    imageMetadata.imageHeight = destSize.height;

    // Write Graphics Control Extension.
    if (writeGraphicsControlExtension) {
        writeGraphicControlExtension(imageMetadata);
    }

    // Write extension blocks.
    writePlainTextExtension(imageMetadata);
    writeApplicationExtension(imageMetadata);
    writeCommentExtension(imageMetadata);

    // Write Image Descriptor
    int bitsPerPixel =
        getNumBits(imageMetadata.localColorTable == null ?
                   (globalColorTable == null ?
                    sampleModel.getSampleSize(0) :
                    globalColorTable.length/3) :
                   imageMetadata.localColorTable.length/3);
    writeImageDescriptor(imageMetadata, bitsPerPixel);

    // Write image data
    writeRasterData(image, sourceBounds, destSize,
                    param, imageMetadata.interlaceFlag);
}
 
Example 12
Source File: GIFImageWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Writes any extension blocks, the Image Descriptor, and the image data
 *
 * @param iioimage The image and image metadata.
 * @param param The write parameters.
 * @param globalColorTable The Global Color Table.
 * @param sourceBounds The source region.
 * @param destSize The destination dimensions.
 */
private void writeImage(RenderedImage image,
                        GIFWritableImageMetadata imageMetadata,
                        ImageWriteParam param, byte[] globalColorTable,
                        Rectangle sourceBounds, Dimension destSize)
  throws IOException {
    ColorModel colorModel = image.getColorModel();
    SampleModel sampleModel = image.getSampleModel();

    boolean writeGraphicsControlExtension;
    if (imageMetadata == null) {
        // Create default metadata.
        imageMetadata = (GIFWritableImageMetadata)getDefaultImageMetadata(
            new ImageTypeSpecifier(image), param);

        // Set GraphicControlExtension flag only if there is
        // transparency.
        writeGraphicsControlExtension = imageMetadata.transparentColorFlag;
    } else {
        // Check for GraphicControlExtension element.
        NodeList list = null;
        try {
            IIOMetadataNode root = (IIOMetadataNode)
                imageMetadata.getAsTree(IMAGE_METADATA_NAME);
            list = root.getElementsByTagName("GraphicControlExtension");
        } catch(IllegalArgumentException iae) {
            // Should never happen.
        }

        // Set GraphicControlExtension flag if element present.
        writeGraphicsControlExtension =
            list != null && list.getLength() > 0;

        // If progressive mode is not MODE_COPY_FROM_METADATA, ensure
        // the interlacing is set per the ImageWriteParam mode setting.
        if (param != null && param.canWriteProgressive()) {
            if (param.getProgressiveMode() ==
                ImageWriteParam.MODE_DISABLED) {
                imageMetadata.interlaceFlag = false;
            } else if (param.getProgressiveMode() ==
                       ImageWriteParam.MODE_DEFAULT) {
                imageMetadata.interlaceFlag = true;
            }
        }
    }

    // Unset local color table if equal to global color table.
    if (Arrays.equals(globalColorTable, imageMetadata.localColorTable)) {
        imageMetadata.localColorTable = null;
    }

    // Override dimensions
    imageMetadata.imageWidth = destSize.width;
    imageMetadata.imageHeight = destSize.height;

    // Write Graphics Control Extension.
    if (writeGraphicsControlExtension) {
        writeGraphicControlExtension(imageMetadata);
    }

    // Write extension blocks.
    writePlainTextExtension(imageMetadata);
    writeApplicationExtension(imageMetadata);
    writeCommentExtension(imageMetadata);

    // Write Image Descriptor
    int bitsPerPixel =
        getNumBits(imageMetadata.localColorTable == null ?
                   (globalColorTable == null ?
                    sampleModel.getSampleSize(0) :
                    globalColorTable.length/3) :
                   imageMetadata.localColorTable.length/3);
    writeImageDescriptor(imageMetadata, bitsPerPixel);

    // Write image data
    writeRasterData(image, sourceBounds, destSize,
                    param, imageMetadata.interlaceFlag);
}
 
Example 13
Source File: ImageUtil.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns whether the image has contiguous data across rows.
 */
public static final boolean imageIsContiguous(RenderedImage image) {
    SampleModel sm;
    if(image instanceof BufferedImage) {
        WritableRaster ras = ((BufferedImage)image).getRaster();
        sm = ras.getSampleModel();
    } else {
        sm = image.getSampleModel();
    }

    if (sm instanceof ComponentSampleModel) {
        // Ensure image rows samples are stored contiguously
        // in a single bank.
        ComponentSampleModel csm = (ComponentSampleModel)sm;

        if (csm.getPixelStride() != csm.getNumBands()) {
            return false;
        }

        int[] bandOffsets = csm.getBandOffsets();
        for (int i = 0; i < bandOffsets.length; i++) {
            if (bandOffsets[i] != i) {
                return false;
            }
        }

        int[] bankIndices = csm.getBankIndices();
        for (int i = 0; i < bandOffsets.length; i++) {
            if (bankIndices[i] != 0) {
                return false;
            }
        }

        return true;
    }

    // Otherwise true if and only if it's a bilevel image with
    // a MultiPixelPackedSampleModel, 1 bit per pixel, and 1 bit
    // pixel stride.
    return ImageUtil.isBinary(sm);
}
 
Example 14
Source File: ImageUtil.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns whether the image has contiguous data across rows.
 */
public static final boolean imageIsContiguous(RenderedImage image) {
    SampleModel sm;
    if(image instanceof BufferedImage) {
        WritableRaster ras = ((BufferedImage)image).getRaster();
        sm = ras.getSampleModel();
    } else {
        sm = image.getSampleModel();
    }

    if (sm instanceof ComponentSampleModel) {
        // Ensure image rows samples are stored contiguously
        // in a single bank.
        ComponentSampleModel csm = (ComponentSampleModel)sm;

        if (csm.getPixelStride() != csm.getNumBands()) {
            return false;
        }

        int[] bandOffsets = csm.getBandOffsets();
        for (int i = 0; i < bandOffsets.length; i++) {
            if (bandOffsets[i] != i) {
                return false;
            }
        }

        int[] bankIndices = csm.getBankIndices();
        for (int i = 0; i < bandOffsets.length; i++) {
            if (bankIndices[i] != 0) {
                return false;
            }
        }

        return true;
    }

    // Otherwise true if and only if it's a bilevel image with
    // a MultiPixelPackedSampleModel, 1 bit per pixel, and 1 bit
    // pixel stride.
    return ImageUtil.isBinary(sm);
}
 
Example 15
Source File: ImageUtil.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Returns whether the image has contiguous data across rows.
 */
public static final boolean imageIsContiguous(RenderedImage image) {
    SampleModel sm;
    if(image instanceof BufferedImage) {
        WritableRaster ras = ((BufferedImage)image).getRaster();
        sm = ras.getSampleModel();
    } else {
        sm = image.getSampleModel();
    }

    if (sm instanceof ComponentSampleModel) {
        // Ensure image rows samples are stored contiguously
        // in a single bank.
        ComponentSampleModel csm = (ComponentSampleModel)sm;

        if (csm.getPixelStride() != csm.getNumBands()) {
            return false;
        }

        int[] bandOffsets = csm.getBandOffsets();
        for (int i = 0; i < bandOffsets.length; i++) {
            if (bandOffsets[i] != i) {
                return false;
            }
        }

        int[] bankIndices = csm.getBankIndices();
        for (int i = 0; i < bandOffsets.length; i++) {
            if (bankIndices[i] != 0) {
                return false;
            }
        }

        return true;
    }

    // Otherwise true if and only if it's a bilevel image with
    // a MultiPixelPackedSampleModel, 1 bit per pixel, and 1 bit
    // pixel stride.
    return ImageUtil.isBinary(sm);
}
 
Example 16
Source File: GIFImageWriter.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Writes any extension blocks, the Image Descriptor, and the image data
 *
 * @param iioimage The image and image metadata.
 * @param param The write parameters.
 * @param globalColorTable The Global Color Table.
 * @param sourceBounds The source region.
 * @param destSize The destination dimensions.
 */
private void writeImage(RenderedImage image,
                        GIFWritableImageMetadata imageMetadata,
                        ImageWriteParam param, byte[] globalColorTable,
                        Rectangle sourceBounds, Dimension destSize)
  throws IOException {
    ColorModel colorModel = image.getColorModel();
    SampleModel sampleModel = image.getSampleModel();

    boolean writeGraphicsControlExtension;
    if (imageMetadata == null) {
        // Create default metadata.
        imageMetadata = (GIFWritableImageMetadata)getDefaultImageMetadata(
            new ImageTypeSpecifier(image), param);

        // Set GraphicControlExtension flag only if there is
        // transparency.
        writeGraphicsControlExtension = imageMetadata.transparentColorFlag;
    } else {
        // Check for GraphicControlExtension element.
        NodeList list = null;
        try {
            IIOMetadataNode root = (IIOMetadataNode)
                imageMetadata.getAsTree(IMAGE_METADATA_NAME);
            list = root.getElementsByTagName("GraphicControlExtension");
        } catch(IllegalArgumentException iae) {
            // Should never happen.
        }

        // Set GraphicControlExtension flag if element present.
        writeGraphicsControlExtension =
            list != null && list.getLength() > 0;

        // If progressive mode is not MODE_COPY_FROM_METADATA, ensure
        // the interlacing is set per the ImageWriteParam mode setting.
        if (param != null && param.canWriteProgressive()) {
            if (param.getProgressiveMode() ==
                ImageWriteParam.MODE_DISABLED) {
                imageMetadata.interlaceFlag = false;
            } else if (param.getProgressiveMode() ==
                       ImageWriteParam.MODE_DEFAULT) {
                imageMetadata.interlaceFlag = true;
            }
        }
    }

    // Unset local color table if equal to global color table.
    if (Arrays.equals(globalColorTable, imageMetadata.localColorTable)) {
        imageMetadata.localColorTable = null;
    }

    // Override dimensions
    imageMetadata.imageWidth = destSize.width;
    imageMetadata.imageHeight = destSize.height;

    // Write Graphics Control Extension.
    if (writeGraphicsControlExtension) {
        writeGraphicControlExtension(imageMetadata);
    }

    // Write extension blocks.
    writePlainTextExtension(imageMetadata);
    writeApplicationExtension(imageMetadata);
    writeCommentExtension(imageMetadata);

    // Write Image Descriptor
    int bitsPerPixel =
        getNumBits(imageMetadata.localColorTable == null ?
                   (globalColorTable == null ?
                    sampleModel.getSampleSize(0) :
                    globalColorTable.length/3) :
                   imageMetadata.localColorTable.length/3);
    writeImageDescriptor(imageMetadata, bitsPerPixel);

    // Write image data
    writeRasterData(image, sourceBounds, destSize,
                    param, imageMetadata.interlaceFlag);
}
 
Example 17
Source File: ImageTypeSpecifier.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs an <code>ImageTypeSpecifier</code> from a
 * <code>RenderedImage</code>.  If a <code>BufferedImage</code> is
 * being used, one of the factory methods
 * <code>createFromRenderedImage</code> or
 * <code>createFromBufferedImageType</code> should be used instead in
 * order to get a more accurate result.
 *
 * @param image a <code>RenderedImage</code>.
 *
 * @exception IllegalArgumentException if the argument is
 * <code>null</code>.
 */
public ImageTypeSpecifier(RenderedImage image) {
    if (image == null) {
        throw new IllegalArgumentException("image == null!");
    }
    colorModel = image.getColorModel();
    sampleModel = image.getSampleModel();
}
 
Example 18
Source File: ImageTypeSpecifier.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs an <code>ImageTypeSpecifier</code> from a
 * <code>RenderedImage</code>.  If a <code>BufferedImage</code> is
 * being used, one of the factory methods
 * <code>createFromRenderedImage</code> or
 * <code>createFromBufferedImageType</code> should be used instead in
 * order to get a more accurate result.
 *
 * @param image a <code>RenderedImage</code>.
 *
 * @exception IllegalArgumentException if the argument is
 * <code>null</code>.
 */
public ImageTypeSpecifier(RenderedImage image) {
    if (image == null) {
        throw new IllegalArgumentException("image == null!");
    }
    colorModel = image.getColorModel();
    sampleModel = image.getSampleModel();
}
 
Example 19
Source File: ImageTypeSpecifier.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * Constructs an <code>ImageTypeSpecifier</code> from a
 * <code>RenderedImage</code>.  If a <code>BufferedImage</code> is
 * being used, one of the factory methods
 * <code>createFromRenderedImage</code> or
 * <code>createFromBufferedImageType</code> should be used instead in
 * order to get a more accurate result.
 *
 * @param image a <code>RenderedImage</code>.
 *
 * @exception IllegalArgumentException if the argument is
 * <code>null</code>.
 */
public ImageTypeSpecifier(RenderedImage image) {
    if (image == null) {
        throw new IllegalArgumentException("image == null!");
    }
    colorModel = image.getColorModel();
    sampleModel = image.getSampleModel();
}
 
Example 20
Source File: ImageTypeSpecifier.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs an <code>ImageTypeSpecifier</code> from a
 * <code>RenderedImage</code>.  If a <code>BufferedImage</code> is
 * being used, one of the factory methods
 * <code>createFromRenderedImage</code> or
 * <code>createFromBufferedImageType</code> should be used instead in
 * order to get a more accurate result.
 *
 * @param image a <code>RenderedImage</code>.
 *
 * @exception IllegalArgumentException if the argument is
 * <code>null</code>.
 */
public ImageTypeSpecifier(RenderedImage image) {
    if (image == null) {
        throw new IllegalArgumentException("image == null!");
    }
    colorModel = image.getColorModel();
    sampleModel = image.getSampleModel();
}