Use is subject to License Terms. Your use of this web site or any of its content or software indicates your agreement to be bound by these License Terms.

Copyright © 2006 Sun Microsystems, Inc. All rights reserved.

JSR-209 (Final Approval Ballot)

javax.imageio
Class ImageTypeSpecifier

java.lang.Object
  extended byjavax.imageio.ImageTypeSpecifier

public class ImageTypeSpecifier
extends java.lang.Object

A class that allows the format of an image (in particular, its SampleModel and ColorModel) to be specified in a convenient manner.

Restrictions

Contructors of this class may only accept SampleModel system instances, those created internally and returned using accessor method calls such as, BufferedImage.getSampleModel(). Instances created directly through invocation of the SampleModel constructor will result in an IllegalArgumentException.

See Also:
SampleModel

Field Summary
protected  java.awt.image.ColorModel colorModel
          The ColorModel to be used as a prototype.
protected  SampleModel sampleModel
          A SampleModel to be used as a prototype.
 
Constructor Summary
ImageTypeSpecifier(java.awt.image.ColorModel colorModel, SampleModel sampleModel)
          Constructs an ImageTypeSpecifier directly from a ColorModel and a SampleModel.
ImageTypeSpecifier(RenderedImage image)
          Constructs an ImageTypeSpecifier from a RenderedImage.
 
Method Summary
static ImageTypeSpecifier createFromRenderedImage(RenderedImage image)
          Returns an ImageTypeSpecifier that encodes the layout of a RenderedImage (which may be a BufferedImage).
 boolean equals(java.lang.Object o)
          Returns true if the given Object is an ImageTypeSpecifier and has a SampleModel and ColorModel that are equal to those of this object.
 int getBufferedImageType()
          Returns an int containing one of the enumerated constant values describing image formats from BufferedImage.
 java.awt.image.ColorModel getColorModel()
          Returns the ColorModel specified by this object.
 int getNumComponents()
          Return the number of color components specified by this object.
 SampleModel getSampleModel()
          Returns a SampleModel based on the settings encapsulated within this object.
 SampleModel getSampleModel(int width, int height)
          Returns a SampleModel based on the settings encapsulated within this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

colorModel

protected java.awt.image.ColorModel colorModel
The ColorModel to be used as a prototype.


sampleModel

protected SampleModel sampleModel
A SampleModel to be used as a prototype.

Constructor Detail

ImageTypeSpecifier

public ImageTypeSpecifier(java.awt.image.ColorModel colorModel,
                          SampleModel sampleModel)
Constructs an ImageTypeSpecifier directly from a ColorModel and a SampleModel. It is the caller's responsibility to supply compatible parameters.

Parameters:
colorModel - a ColorModel.
sampleModel - a SampleModel.
Throws:
java.lang.IllegalArgumentException - if either parameter is null.
java.lang.IllegalArgumentException - if sampleModel is not compatible with colorModel.
java.lang.IllegalArgumentException - for instances of SampleModel created directly through invocation of the SampleModel constructor.

ImageTypeSpecifier

public ImageTypeSpecifier(RenderedImage image)
Constructs an ImageTypeSpecifier from a RenderedImage. If a BufferedImage is being used, one of the factory methods createFromRenderedImage or createFromBufferedImageType should be used instead in order to get a more accurate result.

Parameters:
image - a RenderedImage.
Throws:
java.lang.IllegalArgumentException - if the argument is null or not a BufferedImage. See restriction on RenderedImage.
java.lang.IllegalArgumentException - for instances of SampleModel created directly through invocation of the SampleModel
Method Detail

createFromRenderedImage

public static ImageTypeSpecifier createFromRenderedImage(RenderedImage image)
Returns an ImageTypeSpecifier that encodes the layout of a RenderedImage (which may be a BufferedImage).

Parameters:
image - a RenderedImage.
Returns:
an ImageTypeSpecifier with the desired characteristics.
Throws:
java.lang.IllegalArgumentException - if image is null or not a BufferedImage. See restriction on RenderedImage.

getBufferedImageType

public int getBufferedImageType()
Returns an int containing one of the enumerated constant values describing image formats from BufferedImage.

Returns:
an int representing a BufferedImage type.
See Also:
BufferedImage, BufferedImage.TYPE_CUSTOM, BufferedImage.TYPE_INT_RGB, BufferedImage.TYPE_INT_ARGB, BufferedImage.TYPE_INT_ARGB_PRE, BufferedImage.TYPE_INT_BGR, java.awt.image.BufferedImage#TYPE_3BYTE_BGR, java.awt.image.BufferedImage#TYPE_4BYTE_ABGR, java.awt.image.BufferedImage#TYPE_4BYTE_ABGR_PRE, BufferedImage.TYPE_USHORT_565_RGB, BufferedImage.TYPE_USHORT_555_RGB, java.awt.image.BufferedImage#TYPE_BYTE_GRAY, java.awt.image.BufferedImage#TYPE_USHORT_GRAY, BufferedImage.TYPE_BYTE_BINARY, BufferedImage.TYPE_BYTE_INDEXED

getNumComponents

public int getNumComponents()
Return the number of color components specified by this object. This is the same value as returned by ColorModel.getNumComponents

Returns:
the number of components in the image.

getSampleModel

public SampleModel getSampleModel()
Returns a SampleModel based on the settings encapsulated within this object. The width and height of the SampleModel will be set to arbitrary values.

Returns:
a SampleModel with arbitrary dimensions.

getSampleModel

public SampleModel getSampleModel(int width,
                                  int height)
Returns a SampleModel based on the settings encapsulated within this object. The width and height of the SampleModel will be set to the supplied values.

Parameters:
width - the desired width of the returned SampleModel.
height - the desired height of the returned SampleModel.
Returns:
a SampleModel with the given dimensions.
Throws:
java.lang.IllegalArgumentException - if either width or height are negative or zero.
java.lang.IllegalArgumentException - if the product of width and height is greater than Integer.MAX_VALUE

getColorModel

public java.awt.image.ColorModel getColorModel()
Returns the ColorModel specified by this object.

Returns:
a ColorModel.

equals

public boolean equals(java.lang.Object o)
Returns true if the given Object is an ImageTypeSpecifier and has a SampleModel and ColorModel that are equal to those of this object.

Parameters:
o - the Object to be compared for equality.
Returns:
true if the given object is an equivalent ImageTypeSpecifier.

JSR-209 (Final Approval Ballot)

Copyright © 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to License Terms. Your use of this web site or any of its content or software indicates your agreement to be bound by these License Terms.

For more information, please consult the JSR 209 specification.