JavaTM 2 Platform
Standard Ed. 6

javax.imageio
類別 ImageTypeSpecifier

java.lang.Object
  繼承者 javax.imageio.ImageTypeSpecifier

public class ImageTypeSpecifier
extends Object

允許以便捷方式指定圖像格式(尤其是其 SampleModel 和 ColorModel)的類別。


欄位摘要
protected  ColorModel colorModel
          將用作原型的 ColorModel。
protected  SampleModel sampleModel
          將用作原型的 SampleModel。
 
建構子摘要
ImageTypeSpecifier(ColorModel colorModel, SampleModel sampleModel)
          直接根據 ColorModel 和 SampleModel 建構一個 ImageTypeSpecifier。
ImageTypeSpecifier(RenderedImage image)
          根據 RenderedImage 建構一個 ImageTypeSpecifier。
 
方法摘要
static ImageTypeSpecifier createBanded(ColorSpace colorSpace, int[] bankIndices, int[] bandOffsets, int dataType, boolean hasAlpha, boolean isAlphaPremultiplied)
          返回帶狀圖像格式的說明符,它將使用 ComponentColorModel 和 BandedSampleModel 來存儲單獨陣列中的每個通道。
 BufferedImage createBufferedImage(int width, int height)
          根據此物件中包含的規範創建一個具有給定寬度和高度的 BufferedImage。
static ImageTypeSpecifier createFromBufferedImageType(int bufferedImageType)
          返回一個 ImageTypeSpecifier,它將對某一標準 BufferedImage 型別(而不是 TYPE_CUSTOM)進行編碼。
static ImageTypeSpecifier createFromRenderedImage(RenderedImage image)
          返回一個 ImageTypeSpecifier,它將對 RenderedImage(可能是 BufferedImage)的佈局進行編碼。
static ImageTypeSpecifier createGrayscale(int bits, int dataType, boolean isSigned)
          返回灰度級圖像格式的說明符,它會將給定位深 (bit depth) 的像素壓縮成指定資料型別的陣列元素。
static ImageTypeSpecifier createGrayscale(int bits, int dataType, boolean isSigned, boolean isAlphaPremultiplied)
          返回灰度級圖像格式和 alpha 圖像格式的說明符,它會將給定位深的像素壓縮成指定資料型別的陣列元素。
static ImageTypeSpecifier createIndexed(byte[] redLUT, byte[] greenLUT, byte[] blueLUT, byte[] alphaLUT, int bits, int dataType)
          返回索引顏色圖像格式的說明符,它將給定位深的索引值壓縮成指定資料型別的陣列元素。
static ImageTypeSpecifier createInterleaved(ColorSpace colorSpace, int[] bandOffsets, int dataType, boolean hasAlpha, boolean isAlphaPremultiplied)
          返回交錯圖像格式的說明符,它將使用 ComponentColorModel 和 PixelInterleavedSampleModel 來存儲單個 byte、short 或 int 值形式的每個像素元件。
static ImageTypeSpecifier createPacked(ColorSpace colorSpace, int redMask, int greenMask, int blueMask, int alphaMask, int transferType, boolean isAlphaPremultiplied)
          返回壓縮圖像格式的說明符,它將使用 DirectColorModel 和一個壓縮的 SampleModel 來存儲壓縮成單個 byte、short 或 int 值的像素。
 boolean equals(Object o)
          如果給定 Object 是一個 ImageTypeSpecifier 並且具有與此物件相同的 SampleModel 和 ColorModel,則返回 true。
 int getBitsPerBand(int band)
          返回用來表示給定 band 樣本的位數。
 int getBufferedImageType()
          返回一個 int 值,它包含某一來自 BufferedImage 的描述圖像的列舉常數值。
 ColorModel getColorModel()
          返回此物件指定的 ColorModel。
 int getNumBands()
          返回此物件指定的 band 數。
 int getNumComponents()
          返回此物件指定的顏色元件的數量。
 SampleModel getSampleModel()
          根據此物件中封裝的設置返回一個 SampleModel。
 SampleModel getSampleModel(int width, int height)
          根據此物件中封裝的設置值返回一個 SampleModel。
 int hashCode()
          返回此 ImageTypeSpecifier 的雜湊碼。
 
從類別 java.lang.Object 繼承的方法
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

欄位詳細資訊

colorModel

protected ColorModel colorModel
將用作原型的 ColorModel。


sampleModel

protected SampleModel sampleModel
將用作原型的 SampleModel。

建構子詳細資訊

ImageTypeSpecifier

public ImageTypeSpecifier(ColorModel colorModel,
                          SampleModel sampleModel)
直接根據 ColorModel 和 SampleModel 建構一個 ImageTypeSpecifier。由調用者負責提供相容的參數。

參數:
colorModel - 一個 ColorModel。
sampleModel - 一個 SampleModel。
拋出:
IllegalArgumentException - 如果任意一個參數為 null。
IllegalArgumentException - 如果 sampleModel 與 colorModel 不相容。

ImageTypeSpecifier

public ImageTypeSpecifier(RenderedImage image)
根據 RenderedImage 建構一個 ImageTypeSpecifier。如果使用的是 BufferedImage,為了獲得更精確的結果,應該使用 createFromRenderedImage 或 createFromBufferedImageType 這兩個處理器方法之一。

參數:
image - 一個 RenderedImage。
拋出:
IllegalArgumentException - 如果該參數為 null。
方法詳細資訊

createPacked

public static ImageTypeSpecifier createPacked(ColorSpace colorSpace,
                                              int redMask,
                                              int greenMask,
                                              int blueMask,
                                              int alphaMask,
                                              int transferType,
                                              boolean isAlphaPremultiplied)
返回壓縮圖像格式的說明符,它將使用 DirectColorModel 和一個壓縮的 SampleModel 來存儲壓縮成單個 byte、short 或 int 值的像素。

參數:
colorSpace - 所需的 ColorSpace。
redMask - 指示紅色通道位置的鄰接遮罩碼。
greenMask - 指示綠色通道位置的鄰接遮罩碼。
blueMask - 指示藍色通道位置的鄰接遮罩碼。
alphaMask - 指示 alpha 通道位置的鄰接遮罩碼。
transferType - 所需的 SampleModel 傳輸型別。
isAlphaPremultiplied - 如果顏色通道將預乘以 alpha 通道,則該參數為 true。
返回:
具有所需特徵的 ImageTypeSpecifier。
拋出:
IllegalArgumentException - 如果 colorSpace 為 null。
IllegalArgumentException - 如果 colorSpace 的型別不是 TYPE_RGB。
IllegalArgumentException - 如果沒有遮罩碼至少有一個位集。
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 - 指示每個 band 的偏移量的 int 陣列。
dataType - 所需的資料型別,它是 DataBuffer 類別中的列舉之一。
hasAlpha - 如果需要 alpha 通道,則該參數為 true。
isAlphaPremultiplied - 如果顏色通道將預乘以 alpha 通道,則該參數為 true。
返回:
具有所需特徵的 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 陣列,指示用來存儲每個 band 的資源庫。
bandOffsets - 一個 int 陣列,指示其資源庫中每個 band 的起始偏移量。
dataType - 所需的資料型別,它是 DataBuffer 類別中的列舉之一。
hasAlpha - 如果需要 alpha 通道,則該參數為 true。
isAlphaPremultiplied - 如果顏色通道將預乘以 alpha 通道,則該參數為 true。
返回:
具有所需特徵的 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)
返回灰度級圖像格式的說明符,它會將給定位深 (bit depth) 的像素壓縮成指定資料型別的陣列元素。

參數:
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 - 如果亮度通道將乘以 alpha 通道,則該參數為 true。
返回:
具有所需特徵的 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 陣列,包含每個索引的 red 值。
greenLUT - 一個 byte 陣列,包含每個索引的 green 值。
blueLUT - 一個 byte 陣列,包含每個索引的 blue 值。
alphaLUT - 一個 byte 陣列,包含每個索引的 alpha 值;或者為 null,表示創建一個完全不透明的 LUT。
bits - 每個索引中的位數。
dataType - 所需的輸出型別,它是 DataBuffer 類別中的列舉之一。
返回:
具有所需特徵的 ImageTypeSpecifier。
拋出:
IllegalArgumentException - 如果 redLUT 為 null。
IllegalArgumentException - 如果 greenLUT 為 null。
IllegalArgumentException - 如果 blueLUT 為 null。
IllegalArgumentException - 如果 bits 不是 1、2、4、8 或 16 之一。
IllegalArgumentException - 如果非 null LUT 參數的長度不能正好滿足 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 - 一個 RenderedImage。
返回:
具有所需特徵的 ImageTypeSpecifier。
拋出:
IllegalArgumentException - 如果 image 為 null。

getBufferedImageType

public int getBufferedImageType()
返回一個 int 值,它包含某一來自 BufferedImage 的描述圖像的列舉常數值。

返回:
表示 BufferedImage 型別的 int。
另請參見:
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 返回的值。

返回:
圖像中的 band 數。

getBitsPerBand

public int getBitsPerBand(int band)
返回用來表示給定 band 樣本的位數。

參數:
band - 將被查詢的 band 的索引(int 值形式)。
返回:
指定位數的 int 值。
拋出:
IllegalArgumentException - 如果 band 為負或大於最大 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,則返回 true。

覆寫:
類別 Object 中的 equals
參數:
o - 將用於相等性比較的 Object。
返回:
如果給定物件是一個等價的 ImageTypeSpecifier,則返回 true。
另請參見:
Object.hashCode(), Hashtable

hashCode

public int hashCode()
返回此 ImageTypeSpecifier 的雜湊碼。

覆寫:
類別 Object 中的 hashCode
返回:
此 ImageTypeSpecifier 的雜湊碼
另請參見:
Object.equals(java.lang.Object), Hashtable

JavaTM 2 Platform
Standard Ed. 6

提交錯誤或意見

版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。