- java.lang.Object
-
- javax.imageio.ImageTypeSpecifier
-
public class ImageTypeSpecifier extends Object
允许以方便的方式指定图像格式(特别是其SampleModel和ColorModel)的类。
-
-
字段汇总
字段 变量和类型 字段 描述 protected ColorModelcolorModelColorModel被用作原型。protected SampleModelsampleModelSampleModel用作原型。
-
构造方法摘要
构造方法 构造器 描述 ImageTypeSpecifier(ColorModel colorModel, SampleModel sampleModel)构造一个ImageTypeSpecifier直接从ColorModel和SampleModel。ImageTypeSpecifier(RenderedImage image)构造ImageTypeSpecifier来自RenderedImage。
-
方法摘要
所有方法 静态方法 实例方法 具体的方法 变量和类型 方法 描述 static ImageTypeSpecifiercreateBanded(ColorSpace colorSpace, int[] bankIndices, int[] bandOffsets, int dataType, boolean hasAlpha, boolean isAlphaPremultiplied)返回带状图像格式的说明符,该格式将使用ComponentColorModel和BandedSampleModel将每个通道存储在单独的数组中。BufferedImagecreateBufferedImage(int width, int height)根据此对象中包含的规范创建具有给定宽度和高度的BufferedImage。static ImageTypeSpecifiercreateFromBufferedImageType(int bufferedImageType)返回ImageTypeSpecifier,编码标准BufferedImage类型之一(TYPE_CUSTOM)。static ImageTypeSpecifiercreateFromRenderedImage(RenderedImage image)返回ImageTypeSpecifier,其编码RenderedImage(可能是BufferedImage)的布局。static ImageTypeSpecifiercreateGrayscale(int bits, int dataType, boolean isSigned)返回灰度图像格式的说明符,该格式将给定位深度的像素打包到指定数据类型的数组元素中。static ImageTypeSpecifiercreateGrayscale(int bits, int dataType, boolean isSigned, boolean isAlphaPremultiplied)返回灰度加alpha图像格式的说明符,该格式将给定位深度的像素打包到指定数据类型的数组元素中。static ImageTypeSpecifiercreateIndexed(byte[] redLUT, byte[] greenLUT, byte[] blueLUT, byte[] alphaLUT, int bits, int dataType)返回索引颜色图像格式的说明符,该格式将给定位深度的索引值打包到指定数据类型的数组元素中。static ImageTypeSpecifiercreateInterleaved(ColorSpace colorSpace, int[] bandOffsets, int dataType, boolean hasAlpha, boolean isAlphaPremultiplied)返回交错图像格式的说明符,该格式将使用ComponentColorModel和PixelInterleavedSampleModel将每个像素组件存储在单独的byte,short或int中。static ImageTypeSpecifiercreatePacked(ColorSpace colorSpace, int redMask, int greenMask, int blueMask, int alphaMask, int transferType, boolean isAlphaPremultiplied)返回打包图像格式的说明符,该格式将使用DirectColorModel和打包SampleModel将打包的每个像素存储在单个字节,short或int中。booleanequals(Object o)如果给定的Object是ImageTypeSpecifier并且具有与此对象相同的SampleModel和ColorModel,则返回true。intgetBitsPerBand(int band)返回用于表示给定波段样本的位数。intgetBufferedImageType()返回一个int,其中包含一个描述图像格式的枚举常量值,该值来自BufferedImage。ColorModelgetColorModel()返回此对象指定的ColorModel。intgetNumBands()返回此对象指定的band数。intgetNumComponents()返回此对象指定的颜色分量数。SampleModelgetSampleModel()根据此对象中封装的设置返回SampleModel。SampleModelgetSampleModel(int width, int height)根据此对象中封装的设置返回SampleModel。inthashCode()返回此ImageTypeSpecifier的哈希码。
-
-
-
字段详细信息
-
colorModel
protected ColorModel colorModel
ColorModel用作原型。
-
sampleModel
protected SampleModel sampleModel
SampleModel用作原型。
-
-
构造方法详细信息
-
ImageTypeSpecifier
public ImageTypeSpecifier(ColorModel colorModel, SampleModel sampleModel)
构造一个ImageTypeSpecifier直接从ColorModel和SampleModel。 呼叫者有责任提供兼容的参数。- 参数
-
colorModel- aColorModel。 -
sampleModel- 长SampleModel。 - 异常
-
IllegalArgumentException- 如果任一参数为null。 -
IllegalArgumentException- 如果sampleModel与colorModel不兼容。
-
ImageTypeSpecifier
public ImageTypeSpecifier(RenderedImage image)
构造ImageTypeSpecifier来自RenderedImage。 如果BufferedImage正在使用的,出厂的方法之一createFromRenderedImage或createFromBufferedImageType应改为使用,以获得更精确的结果。- 参数
-
image- aRenderedImage。 - 异常
-
IllegalArgumentException- 如果参数是null。
-
-
方法详细信息
-
createPacked
public static ImageTypeSpecifier createPacked(ColorSpace colorSpace, int redMask, int greenMask, int blueMask, int alphaMask, int transferType, boolean isAlphaPremultiplied)
返回打包图像格式的说明符,该格式将使用DirectColorModel和打包SampleModel将每个像素打包到单个字节,short或int中。- 参数
-
colorSpace- 所需的ColorSpace。 -
redMask- 连续的掩码表示红色通道的位置。 -
greenMask- 连续的掩码表示绿色通道的位置。 -
blueMask- 连续的掩码表示蓝色通道的位置。 -
alphaMask- 连续的掩码表示alpha通道的位置。 -
transferType- 所需的SampleModel传输类型。 -
isAlphaPremultiplied-true如果颜色通道将由Alpha通道预乘。 - 结果
-
具有所需特征的
ImageTypeSpecifier。 - 异常
-
IllegalArgumentException- 如果colorSpace是null。 -
IllegalArgumentException- 如果colorSpace不是TYPE_RGB的类型。 -
IllegalArgumentException- 如果没有掩码至少设置了1位。 -
IllegalArgumentException-如果transferType如果不是一个DataBuffer.TYPE_BYTE,DataBuffer.TYPE_USHORT,或DataBuffer.TYPE_INT。
-
createInterleaved
public static ImageTypeSpecifier createInterleaved(ColorSpace colorSpace, int[] bandOffsets, int dataType, boolean hasAlpha, boolean isAlphaPremultiplied)
返回交错图像格式的说明符,该格式将使用ComponentColorModel和PixelInterleavedSampleModel将每个像素组件存储在单独的byte,short或int中。- 参数
-
colorSpace- 所需的ColorSpace。 -
bandOffsets-的阵列int以及指示每个波段的偏移。 -
dataType- 所需的数据类型,作为DataBuffer类的枚举之一。 -
hasAlpha-true如果需要alpha通道。 -
isAlphaPremultiplied-true如果颜色通道将由Alpha通道预乘。 - 结果
-
具有所需特征的
ImageTypeSpecifier。 - 异常
-
IllegalArgumentException- 如果colorSpace是null。 -
IllegalArgumentException- 如果bandOffsets是null。 -
IllegalArgumentException- 如果dataType不是合法的DataBuffer.TYPE_*常量之一。 -
IllegalArgumentException- 如果bandOffsets.length不等于颜色空间组件的数量,如果hasAlpha是true,则加1。
-
createBanded
public static ImageTypeSpecifier createBanded(ColorSpace colorSpace, int[] bankIndices, int[] bandOffsets, int dataType, boolean hasAlpha, boolean isAlphaPremultiplied)
返回带状图像格式的说明符,该格式将使用ComponentColorModel和BandedSampleModel将每个通道存储在单独的数组中。- 参数
-
colorSpace- 所需的ColorSpace。 -
bankIndices-的阵列int以及指示,其中每个频带将被存储在银行。 -
bandOffsets-的阵列int以及指示开始其组内的每一频带的偏移。 -
dataType- 所需的数据类型,作为DataBuffer类的枚举之一。 -
hasAlpha-true如果需要alpha通道。 -
isAlphaPremultiplied-true如果颜色通道将由Alpha通道预乘。 - 结果
-
具有所需特征的
ImageTypeSpecifier。 - 异常
-
IllegalArgumentException- 如果colorSpace是null。 -
IllegalArgumentException- 如果bankIndices是null。 -
IllegalArgumentException- 如果bandOffsets是null。 -
IllegalArgumentException- 如果长度bankIndices和bandOffsets不同。 -
IllegalArgumentException- 如果bandOffsets.length不等于颜色空间组件的数量,如果hasAlpha是true,则加1。 -
IllegalArgumentException- 如果dataType不是合法的DataBuffer.TYPE_*常量之一。
-
createGrayscale
public static ImageTypeSpecifier createGrayscale(int bits, int dataType, boolean isSigned)
返回灰度图像格式的说明符,该格式将给定位深度的像素打包到指定数据类型的数组元素中。- 参数
-
bits- 每个灰度值的位数(1,2,4,8或16)。 -
dataType- 所需的数据类型,作为DataBuffer类的枚举之一。 -
isSigned-true如果要表示负值。 - 结果
-
具有所需特征的
ImageTypeSpecifier。 - 异常
-
IllegalArgumentException- 如果bits不是1,2,4,8或16中的一个。 -
IllegalArgumentException-如果dataType不是一个DataBuffer.TYPE_BYTE,DataBuffer.TYPE_SHORT,或DataBuffer.TYPE_USHORT。 -
IllegalArgumentException- 如果bits大于给定的dataType的位大小。
-
createGrayscale
public static ImageTypeSpecifier createGrayscale(int bits, int dataType, boolean isSigned, boolean isAlphaPremultiplied)
返回灰度加alpha图像格式的说明符,该格式将给定位深度的像素打包到指定数据类型的数组元素中。- 参数
-
bits- 每灰度值的位数(1,2,4,8或16)。 -
dataType- 所需的数据类型,作为DataBuffer类的枚举之一。 -
isSigned-true如果要表示负值。 -
isAlphaPremultiplied-true如果亮度通道将由alpha通道预乘。 - 结果
-
具有所需特征的
ImageTypeSpecifier。 - 异常
-
IllegalArgumentException- 如果bits不是1,2,4,8或16中的一个。 -
IllegalArgumentException-如果dataType不是一个DataBuffer.TYPE_BYTE,DataBuffer.TYPE_SHORT,或DataBuffer.TYPE_USHORT。 -
IllegalArgumentException- 如果bits大于给定的dataType的位大小。
-
createIndexed
public static ImageTypeSpecifier createIndexed(byte[] redLUT, byte[] greenLUT, byte[] blueLUT, byte[] alphaLUT, int bits, int dataType)
返回索引颜色图像格式的说明符,该格式将给定位深度的索引值打包到指定数据类型的数组元素中。- 参数
-
redLUT- 包含每个索引的红色值的byte数组。 -
greenLUT- 包含*每个索引的绿色值的byte数组。 -
blueLUT- 包含每个索引的蓝色值的byte数组。 -
alphaLUT- 包含每个索引的alpha值的byte数组,或null以创建完全不透明的LUT。 -
bits- 每个索引中的位数。 -
dataType- 所需的输出类型,作为DataBuffer类的枚举之一。 - 结果
-
具有所需特征的
ImageTypeSpecifier。 - 异常
-
IllegalArgumentException- 如果redLUT是null。 -
IllegalArgumentException- 如果greenLUT是null。 -
IllegalArgumentException- 如果blueLUT是null。 -
IllegalArgumentException- 如果bits不是1,2,4,8或16中的一个。 -
IllegalArgumentException- 如果非nullLUT参数的长度不完全为1 << bits。 -
IllegalArgumentException-如果dataType不是一个DataBuffer.TYPE_BYTE,DataBuffer.TYPE_SHORT,DataBuffer.TYPE_USHORT,或DataBuffer.TYPE_INT。 -
IllegalArgumentException- 如果bits大于给定的dataType的位大小。
-
createFromBufferedImageType
public static ImageTypeSpecifier createFromBufferedImageType(int bufferedImageType)
返回ImageTypeSpecifier,它编码标准BufferedImage类型之一(TYPE_CUSTOM)。- 参数
-
bufferedImageType- 表示标准BufferedImage类型之一的int。 - 结果
-
具有所需特征的
ImageTypeSpecifier。 - 异常
-
IllegalArgumentException- 如果bufferedImageType不是标准类型之一,或等于TYPE_CUSTOM。 - 另请参见:
-
BufferedImage,BufferedImage.TYPE_INT_RGB,BufferedImage.TYPE_INT_ARGB,BufferedImage.TYPE_INT_ARGB_PRE,BufferedImage.TYPE_INT_BGR,BufferedImage.TYPE_3BYTE_BGR,BufferedImage.TYPE_4BYTE_ABGR,BufferedImage.TYPE_4BYTE_ABGR_PRE,BufferedImage.TYPE_USHORT_565_RGB,BufferedImage.TYPE_USHORT_555_RGB,BufferedImage.TYPE_BYTE_GRAY,BufferedImage.TYPE_USHORT_GRAY,BufferedImage.TYPE_BYTE_BINARY,BufferedImage.TYPE_BYTE_INDEXED
-
createFromRenderedImage
public static ImageTypeSpecifier createFromRenderedImage(RenderedImage image)
返回ImageTypeSpecifier,它编码RenderedImage(可能是BufferedImage)的布局。- 参数
-
image- aRenderedImage。 - 结果
-
具有所需特征的
ImageTypeSpecifier。 - 异常
-
IllegalArgumentException- 如果image是null。
-
getBufferedImageType
public int getBufferedImageType()
返回一个int,其中包含一个描述图像格式的枚举常量值,来自BufferedImage。- 结果
-
int代表BufferedImage类型。 - 另请参见:
-
BufferedImage,BufferedImage.TYPE_CUSTOM,BufferedImage.TYPE_INT_RGB,BufferedImage.TYPE_INT_ARGB,BufferedImage.TYPE_INT_ARGB_PRE,BufferedImage.TYPE_INT_BGR,BufferedImage.TYPE_3BYTE_BGR,BufferedImage.TYPE_4BYTE_ABGR,BufferedImage.TYPE_4BYTE_ABGR_PRE,BufferedImage.TYPE_USHORT_565_RGB,BufferedImage.TYPE_USHORT_555_RGB,BufferedImage.TYPE_BYTE_GRAY,BufferedImage.TYPE_USHORT_GRAY,BufferedImage.TYPE_BYTE_BINARY,BufferedImage.TYPE_BYTE_INDEXED
-
getNumComponents
public int getNumComponents()
返回此对象指定的颜色分量数。 这与ColorModel.getNumComponents返回的值相同- 结果
- 图像中的组件数量。
-
getNumBands
public int getNumBands()
返回此对象指定的band数。 这与SampleModel.getNumBands返回的值相同- 结果
- 图像中的波段数。
-
getBitsPerBand
public int getBitsPerBand(int band)
返回用于表示给定波段样本的位数。- 参数
-
band- 要查询的波段的索引,以int为单位。 - 结果
- 指定位数的int。
- 异常
-
IllegalArgumentException- 如果band为负数或大于最大波段指数。
-
getSampleModel
public SampleModel getSampleModel()
根据此对象中封装的设置返回SampleModel。SampleModel的宽度和高度将设置为任意值。- 结果
-
具有任意尺寸的
SampleModel。
-
getSampleModel
public SampleModel getSampleModel(int width, int height)
根据此对象中封装的设置返回SampleModel。SampleModel的宽度和高度将设置为提供的值。- 参数
-
width- 返回SampleModel的所需宽度。 -
height- 返回SampleModel的所需高度。 - 结果
-
具有给定尺寸的
SampleModel。 - 异常
-
IllegalArgumentException- 如果width或height为负数或零。 -
IllegalArgumentException- 如果width和height的产品大于Integer.MAX_VALUE
-
getColorModel
public ColorModel getColorModel()
返回此对象指定的ColorModel。- 结果
-
ColorModel。
-
createBufferedImage
public BufferedImage createBufferedImage(int width, int height)
根据此对象中包含的规范创建具有给定宽度和高度的BufferedImage。- 参数
-
width- 返回BufferedImage的所需宽度。 -
height- 返回BufferedImage的所需高度。 - 结果
-
一个新的
BufferedImage - 异常
-
IllegalArgumentException- 如果width或height为负数或零。 -
IllegalArgumentException- 如果width和height大于Integer.MAX_VALUE,或者存储图像所需的数组元素数大于Integer.MAX_VALUE。
-
equals
public boolean equals(Object o)
如果给定的Object是ImageTypeSpecifier并且具有与此对象的SampleModel和ColorModel相等的ColorModel,则返回true。- 重写:
-
equals类Object - 参数
-
o- 要比较的Object是否相等。 - 结果
-
true如果给定对象是等效的ImageTypeSpecifier。 - 另请参见:
-
Object.hashCode(),HashMap
-
hashCode
public int hashCode()
返回此ImageTypeSpecifier的哈希码。- 重写:
-
hashCode类Object - 结果
- 此ImageTypeSpecifier的哈希码
- 另请参见:
-
Object.equals(java.lang.Object),System.identityHashCode(java.lang.Object)
-
-