- java.lang.Object繼承
-
- java.awt.Image中
-
- java.awt.image.BufferedImage中
-
公共類BufferedImage 擴展Image 實現WritableRenderedImage,Transparency
該BufferedImage
子類描述了一個Image
具有可訪問的圖像數據緩沖區。ABufferedImage
由一個ColorModel
和一個Raster
圖像數據組成。在數量和類型的帶SampleModel
的Raster
必須由所要求的數量和類型相匹配ColorModel
,以表示其顏色和alpha分量。所有BufferedImage
對象的左上角坐標為(0,0)。因此Raster
用於構造a的 任何BufferedImage
必須具有minX = 0和minY = 0。這個類依賴於數據的獲取和設置方法
Raster
,以及顏色表征方法ColorModel
。- 也可以看看:
-
ColorModel
,Raster
,WritableRaster
-
-
字段摘要
字段 修飾符和類型 字段和說明 static int
TYPE_3BYTE_BGR
表示具有8位RGB顏色分量的圖像,對應於Windows風格的BGR顏色模型),其顏色為藍色,綠色和紅色,存儲為3個字節。static int
TYPE_4BYTE_ABGR
表示具有8位RGBA顏色組件的圖像,其顏色為藍色,綠色和紅色,以3字節和1字節的alpha存儲。static int
TYPE_4BYTE_ABGR_PRE
表示具有8位RGBA顏色組件的圖像,其顏色為藍色,綠色和紅色,以3字節和1字節的alpha存儲。static int
TYPE_BYTE_BINARY
表示一個不透明的字節打包的1,2或4位圖像。static int
TYPE_BYTE_GRAY
表示未經過索引的無符號字節灰度圖像。static int
TYPE_BYTE_INDEXED
表示索引字節圖像。static int
TYPE_CUSTOM
圖像類型無法識別,因此它必須是自定義圖像。static int
TYPE_INT_ARGB
表示8位RGBA顏色分量打包成整數像素的圖像。static int
TYPE_INT_ARGB_PRE
表示8位RGBA顏色分量打包成整數像素的圖像。static int
TYPE_INT_BGR
表示具有8位RGB顏色組件的圖像,對應於Windows或Solaris風格的BGR顏色模型,藍色,綠色和紅色包裝為整數像素。static int
TYPE_INT_RGB
表示8位RGB顏色分量打包成整數像素的圖像。static int
TYPE_USHORT_555_RGB
代表具有5-5-5 RGB顏色分量(5位紅色,5位綠色,5位藍色)且不含阿爾法的圖像。static int
TYPE_USHORT_565_RGB
代表具有5-6-5 RGB顏色分量(5位紅色,6位綠色,5位藍色)且不含Alpha的圖像。static int
TYPE_USHORT_GRAY
表示未經過編碼的短灰度圖像,未編制索引)。-
從類java.awt繼承的字段 圖片
accelerationPriority, SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedProperty
-
從接口java.awt繼承的字段。透明度
BITMASK, OPAQUE, TRANSLUCENT
-
-
構造器摘要
構造函數 構造函數和說明 BufferedImage(ColorModel cm, WritableRaster raster, boolean isRasterPremultiplied, Hashtable<?,?> properties)
BufferedImage
用指定的ColorModel
和構造一個新的Raster
。BufferedImage(int width, int height, int imageType)
構造一個BufferedImage
預定義的圖像類型。BufferedImage(int width, int height, int imageType, IndexColorModel cm)
構造一個BufferedImage
預定義的圖像類型:TYPE_BYTE_BINARY或TYPE_BYTE_INDEXED。
-
方法摘要
方法 修飾符和類型 方法和描述 void
addTileObserver(TileObserver to)
添加一個tile觀察者。void
coerceData(boolean isAlphaPremultiplied)
強制數據匹配isAlphaPremultiplied
變量中指定的狀態 。WritableRaster
copyData(WritableRaster outRaster)
計算任意的矩形區域BufferedImage
並將其復制到指定的區域WritableRaster
。Graphics2D
createGraphics()
創建一個Graphics2D
,可以用來繪制這個BufferedImage
。WritableRaster
getAlphaRaster()
返回一個WritableRaster
表示BufferedImage
具有ColorModel
支持單獨空間Alpha通道的對象(如ComponentColorModel
和)的 alpha通道DirectColorModel
。ColorModel
getColorModel()
返回ColorModel
。Raster
getData()
將圖像作為一個大圖塊返回。Raster
getData(Rectangle rect)
計算並返回一個任意的區域BufferedImage
。Graphics
getGraphics()
此方法返回一個Graphics2D
,但在這里是為了向后兼容。int
getHeight()
返回。的高度BufferedImage
。int
getHeight(ImageObserver observer)
返回。的高度BufferedImage
。int
getMinTileX()
返回x方向上的最小圖塊索引。int
getMinTileY()
返回y方向上的最小圖塊索引。int
getMinX()
返回此的最小x坐標BufferedImage
。int
getMinY()
返回此的最小y坐標BufferedImage
。int
getNumXTiles()
返回x方向上的圖塊數量。int
getNumYTiles()
返回y方向上的圖塊數量。Object
getProperty(String name)
按名稱返回圖像的屬性。Object
getProperty(String name, ImageObserver observer)
按名稱返回圖像的屬性。String[]
getPropertyNames()
返回由getProperty(String)
or 識別的名稱數組null
,如果沒有識別屬性名稱。WritableRaster
getRaster()
返回WritableRaster
。int
getRGB(int x, int y)
返回默認RGB顏色模型(TYPE_INT_ARGB)和默認sRGB顏色空間中的整數像素。int[]
getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize)
從部分圖像數據中返回默認RGB顏色模型(TYPE_INT_ARGB)和默認sRGB顏色空間中的整數像素數組。SampleModel
getSampleModel()
返回SampleModel
與此關聯的內容BufferedImage
。ImageProducer
getSource()
返回產生圖像像素的對象。Vector<RenderedImage>
getSources()
BufferedImage
getSubimage(int x, int y, int w, int h)
返回由指定的矩形區域定義的子圖像。Raster
getTile(int tileX, int tileY)
返回平鋪(tileX
,tileY
)。int
getTileGridXOffset()
返回平鋪網格相對於原點的x偏移量,例如平鋪(0,0)位置的x坐標。int
getTileGridYOffset()
返回tile網格相對於原點的y偏移量,例如tile(0,0)位置的y坐標。int
getTileHeight()
以像素為單位返回平鋪高度。int
getTileWidth()
以像素為單位返回圖塊寬度。int
getTransparency()
返回透明度。int
getType()
返回圖像類型。int
getWidth()
返回。的寬度BufferedImage
。int
getWidth(ImageObserver observer)
返回。的寬度BufferedImage
。WritableRaster
getWritableTile(int tileX, int tileY)
檢查一個瓷磚的寫作。Point[]
getWritableTileIndices()
返回一個Point
對象數組,指示檢出哪些圖塊用於寫入。boolean
hasTileWriters()
返回是否檢出任何圖塊進行寫入。boolean
isAlphaPremultiplied()
返回alpha是否已經預乘。boolean
isTileWritable(int tileX, int tileY)
返回平鋪當前是否簽出寫入。void
releaseWritableTile(int tileX, int tileY)
放棄寫入瓦片的權限。void
removeTileObserver(TileObserver to)
刪除一個tile觀察者。void
setData(Raster r)
將圖像的矩形區域設置為指定的內容,Raster
r
假定其位於與坐標軸相同的坐標空間中BufferedImage
。void
setRGB(int x, int y, int rgb)
將其中的像素設置為BufferedImage
指定的RGB值。void
setRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize)
將默認RGB顏色模型(TYPE_INT_ARGB)和默認sRGB顏色空間中的整數像素數組設置為圖像數據的一部分。String
toString()
返回String
此BufferedImage
對象及其值的表示形式 。-
從類java.awt繼承的方法 圖片
flush, getAccelerationPriority, getCapabilities, getScaledInstance, setAccelerationPriority
-
-
-
-
字段細節
-
TYPE_CUSTOM
公共靜態最終詮釋TYPE_CUSTOM
圖像類型無法識別,因此它必須是自定義圖像。此類型僅用作getType()方法的返回值。- 也可以看看:
- 常量字段值
-
TYPE_INT_RGB
公共靜態最終詮釋TYPE_INT_RGB
表示8位RGB顏色分量打包成整數像素的圖像。圖像有一個DirectColorModel
沒有阿爾法。當具有非透明alpha的數據存儲在此類圖像中時,必須將顏色數據調整為非預乘形式,並丟棄alpha,如AlphaComposite
文檔中所述 。- 也可以看看:
- 常量字段值
-
TYPE_INT_ARGB
公共靜態最終詮釋TYPE_INT_ARGB
表示8位RGBA顏色分量打包成整數像素的圖像。圖像有一個DirectColorModel
與阿爾法。該圖像中的顏色數據被認為不是預乘alpha。當此類型用作 構造函數的imageType
參數時BufferedImage
,創建的圖像與在JDK1.1及更早版本中創建的圖像一致。- 也可以看看:
- 常量字段值
-
TYPE_INT_ARGB_PRE
public static final int TYPE_INT_ARGB_PRE
表示8位RGBA顏色分量打包成整數像素的圖像。圖像有一個DirectColorModel
與阿爾法。該圖像中的顏色數據被認為是預乘alpha。- 也可以看看:
- 常量字段值
-
TYPE_INT_BGR
公共靜態最終詮釋TYPE_INT_BGR
表示具有8位RGB顏色組件的圖像,對應於Windows或Solaris風格的BGR顏色模型,藍色,綠色和紅色包裝為整數像素。沒有阿爾法。該圖像有一個DirectColorModel
。當具有非透明alpha的數據存儲在此類圖像中時,必須將顏色數據調整為非預乘形式,並丟棄alpha,如AlphaComposite
文檔中所述 。- 也可以看看:
- 常量字段值
-
TYPE_3BYTE_BGR
公共靜態最終詮釋TYPE_3BYTE_BGR
表示具有8位RGB顏色分量的圖像,對應於Windows風格的BGR顏色模型),其顏色為藍色,綠色和紅色,存儲為3個字節。沒有阿爾法。該圖像有一個ComponentColorModel
。當具有非透明alpha的數據存儲在此類圖像中時,必須將顏色數據調整為非預乘形式,並丟棄alpha,如AlphaComposite
文檔中所述 。- 也可以看看:
- 常量字段值
-
TYPE_4BYTE_ABGR
公共靜態最終詮釋TYPE_4BYTE_ABGR
表示具有8位RGBA顏色組件的圖像,其顏色為藍色,綠色和紅色,以3字節和1字節的alpha存儲。圖像有一個ComponentColorModel
與阿爾法。該圖像中的顏色數據被認為不是預乘alpha。字節數據按每個像素內從低位到高位字節地址的順序A,B,G,R以單個字節陣列交錯。- 也可以看看:
- 常量字段值
-
TYPE_4BYTE_ABGR_PRE
公共靜態最終詮釋TYPE_4BYTE_ABGR_PRE
表示具有8位RGBA顏色組件的圖像,其顏色為藍色,綠色和紅色,以3字節和1字節的alpha存儲。圖像有一個ComponentColorModel
與阿爾法。該圖像中的顏色數據被認為是預乘alpha。字節數據按每個像素內從低位到高位字節地址的順序A,B,G,R以單個字節陣列交錯。- 也可以看看:
- 常量字段值
-
TYPE_USHORT_565_RGB
public static final int TYPE_USHORT_565_RGB
代表具有5-6-5 RGB顏色分量(5位紅色,6位綠色,5位藍色)且不含Alpha的圖像。這個圖像有一個DirectColorModel
。當具有非透明alpha的數據存儲在此類圖像中時,必須將顏色數據調整為非預乘形式,並丟棄alpha,如AlphaComposite
文檔中所述 。- 也可以看看:
- 常量字段值
-
TYPE_USHORT_555_RGB
公共靜態最終詮釋TYPE_USHORT_555_RGB
代表具有5-5-5 RGB顏色分量(5位紅色,5位綠色,5位藍色)且不含阿爾法的圖像。這個圖像有一個DirectColorModel
。當具有非透明alpha的數據存儲在此類圖像中時,必須將顏色數據調整為非預乘形式,並丟棄alpha,如AlphaComposite
文檔中所述 。- 也可以看看:
- 常量字段值
-
TYPE_BYTE_GRAY
公共靜態最終詮釋TYPE_BYTE_GRAY
表示未經過索引的無符號字節灰度圖像。這張圖片有ComponentColorModel
一個CS_GRAYColorSpace
。當具有非透明alpha的數據存儲在此類圖像中時,必須將顏色數據調整為非預乘形式,並丟棄alpha,如AlphaComposite
文檔中所述 。- 也可以看看:
- 常量字段值
-
TYPE_USHORT_GRAY
公共靜態最終詮釋TYPE_USHORT_GRAY
表示未經過編碼的短灰度圖像,未編制索引)。這張圖片有ComponentColorModel
一個CS_GRAYColorSpace
。當具有非透明alpha的數據存儲在此類圖像中時,必須將顏色數據調整為非預乘形式,並丟棄alpha,如AlphaComposite
文檔中所述 。- 也可以看看:
- 常量字段值
-
TYPE_BYTE_BINARY
公共靜態最終詮釋TYPE_BYTE_BINARY
表示一個不透明的字節打包的1,2或4位圖像。圖像有一個IndexColorModel
沒有阿爾法。當此類型用作接受參數但不帶 參數imageType
的BufferedImage
構造imageType
函數的ColorModel
參數時,將IndexColorModel
使用默認sRGB中的兩種顏色創建1位圖像ColorSpace
:{0,0,0}和{255,255,255 }。每像素2或4位的圖像可以通過構造函數來
BufferedImage
構造,該構造ColorModel
函數通過提供ColorModel
具有適當的地圖尺寸的參數來構造 參數 。每像素8位的圖像應該使用圖像類型
TYPE_BYTE_INDEXED
或TYPE_BYTE_GRAY
根據其類型ColorModel
。當顏色數據存儲在此類型的圖像中時,顏色貼圖中最接近的顏色由該項確定,
IndexColorModel
並存儲結果索引。根據顏色IndexColorModel
映射中的顏色,可能會導致逼近和丟失alpha或顏色分量 。- 也可以看看:
- 常量字段值
-
TYPE_BYTE_INDEXED
公共靜態最終詮釋TYPE_BYTE_INDEXED
表示索引字節圖像。當這個類型被用作 帶有參數但沒有參數imageType
的BufferedImage
構造imageType
函數的ColorModel
參數時,IndexColorModel
用256色6/6/6彩色立方體調色板創建一個,其余的顏色從216-255填充到灰度值中默認的sRGB ColorSpace。當顏色數據存儲在此類型的圖像中時,顏色貼圖中最接近的顏色由該項確定,
IndexColorModel
並存儲結果索引。根據顏色IndexColorModel
映射中的顏色,可能會導致逼近和丟失alpha或顏色分量 。- 也可以看看:
- 常量字段值
-
-
構造函數的細節
-
的BufferedImage
public BufferedImage(int width, int高度, int imageType)
構造一個BufferedImage
預定義的圖像類型。該ColorSpace
圖像是默認的sRGB空間。- 參數:
-
width
- 創建的圖像的寬度 -
height
- 創建圖像的高度 -
imageType
- 創建的圖像的類型 - 也可以看看:
-
ColorSpace
,TYPE_INT_RGB
,TYPE_INT_ARGB
,TYPE_INT_ARGB_PRE
,TYPE_INT_BGR
,TYPE_3BYTE_BGR
,TYPE_4BYTE_ABGR
,TYPE_4BYTE_ABGR_PRE
,TYPE_BYTE_GRAY
,TYPE_USHORT_GRAY
,TYPE_BYTE_BINARY
,TYPE_BYTE_INDEXED
,TYPE_USHORT_565_RGB
,TYPE_USHORT_555_RGB
-
的BufferedImage
public BufferedImage(int width, int高度, int imageType, IndexColorModel cm)
構造一個BufferedImage
預定義的圖像類型:TYPE_BYTE_BINARY或TYPE_BYTE_INDEXED。如果圖像類型是TYPE_BYTE_BINARY,則使用顏色模型中的條目數來確定圖像是否應具有每像素1,2或4位。如果顏色模型具有1或2個條目,則圖像將具有每像素1位。如果它具有3或4個條目,則每個像素具有2位的圖像。如果它具有5到16個條目,則圖像將具有每像素4位。否則,將拋出IllegalArgumentException。
- 參數:
-
width
- 創建的圖像的寬度 -
height
- 創建圖像的高度 -
imageType
- 創建的圖像的類型 -
cm
-IndexColorModel
創建的圖像 - 拋出:
-
IllegalArgumentException
- 如果imageType不是TYPE_BYTE_BINARY或TYPE_BYTE_INDEXED,或者imageType是TYPE_BYTE_BINARY,並且顏色映射有超過16個條目。 - 也可以看看:
-
TYPE_BYTE_BINARY
,TYPE_BYTE_INDEXED
-
的BufferedImage
公共BufferedImage(ColorModel cm, WritableRaster 柵格, 布爾isRasterPremultiplied, 散列表 <?,?>屬性)
BufferedImage
用指定的ColorModel
和構造一個新的Raster
。如果在數量和類型的帶SampleModel
的Raster
不匹配的數量和由所要求的類型的ColorModel
表示其顏色和alpha分量,一個RasterFormatException
被拋出。該方法可以將顏色Raster
數據乘以或除以alpha以匹配中的alphaPremultiplied
狀態ColorModel
。屬性BufferedImage
可以通過傳入一Hashtable
對String
/Object
成對來建立。- 參數:
-
cm
-ColorModel
為新的圖像 -
raster
-Raster
用於圖像數據 -
isRasterPremultiplied
- 如果true
光柵中的數據已經預乘alpha。 -
properties
-Hashtable
中String
/Object
對。 - 拋出:
-
-如果在數量和類型的帶RasterFormatException
SampleModel
的Raster
不匹配所要求的數量和類型ColorModel
,以表示其顏色和alpha分量。 -
- 如果IllegalArgumentException
raster
不符合cm
- 也可以看看:
-
ColorModel
,Raster
,WritableRaster
-
-
方法細節
-
的getType
public int getType()
返回圖像類型。如果它不是已知類型之一,則返回TYPE_CUSTOM。- 返回:
-
這個的圖像類型
BufferedImage
。 - 也可以看看:
-
TYPE_INT_RGB
,TYPE_INT_ARGB
,TYPE_INT_ARGB_PRE
,TYPE_INT_BGR
,TYPE_3BYTE_BGR
,TYPE_4BYTE_ABGR
,TYPE_4BYTE_ABGR_PRE
,TYPE_BYTE_GRAY
,TYPE_BYTE_BINARY
,TYPE_BYTE_INDEXED
,TYPE_USHORT_GRAY
,TYPE_USHORT_565_RGB
,TYPE_USHORT_555_RGB
,TYPE_CUSTOM
-
getColorModel
public ColorModel getColorModel()
返回ColorModel
。- 指定者:
-
getColorModel
在界面中RenderedImage
- 返回:
-
在
ColorModel
這BufferedImage
。
-
getRaster
public WritableRaster getRaster()
- 返回:
-
在
WriteableRaster
這BufferedImage
。
-
getAlphaRaster
public WritableRaster getAlphaRaster()
返回一個WritableRaster
表示BufferedImage
具有ColorModel
支持單獨空間Alpha通道的對象(如ComponentColorModel
和)的 alpha通道DirectColorModel
。null
如果沒有與ColorModel
此圖像中的Alpha通道關聯,則返回。此方法假設,對於所有ColorModel
對象以外IndexColorModel
,如果ColorModel
支撐件α,存在被存儲為圖像數據的最后一個頻帶的單獨alpha通道。如果圖像使用IndexColorModel
在查找表中具有alpha 的圖像,則此方法返回,null
因為沒有空間離散的Alpha通道。此方法創建一個新的WritableRaster
,但共享數據數組。- 返回:
-
a
WritableRaster
或者null
如果BufferedImage
沒有與其關聯的Alpha通道ColorModel
。
-
的getRGB
public int getRGB(int x, int y)
返回默認RGB顏色模型(TYPE_INT_ARGB)和默認sRGB顏色空間中的整數像素。如果此默認模型與圖像不匹配,則會發生顏色轉換ColorModel
。使用此方法時,返回數據中的每個顏色分量只有8位精度。ArrayOutOfBoundsException
如果坐標不在邊界內,則可能拋出 一個。但是,顯式邊界檢查不能保證。- 參數:
-
x
- 從默認RGB顏色模型和sRGB顏色空間中獲取像素的像素的X坐標 -
y
- 默認RGB顏色模型和sRGB顏色空間中像素的Y坐標 - 返回:
- 默認RGB顏色模型中的整數像素和默認sRGB顏色空間。
- 也可以看看:
-
setRGB(int, int, int)
,setRGB(int, int, int, int, int[], int, int)
-
的getRGB
public int [] getRGB(int startX, int startY, int w, int h, int [] rgbArray, int偏移量, int scansize)
從部分圖像數據中返回默認RGB顏色模型(TYPE_INT_ARGB)和默認sRGB顏色空間中的整數像素數組。如果默認模型與圖像不匹配,則會進行顏色轉換ColorModel
。使用此方法時,返回數據中的每個顏色分量只有8位精度。使用圖像中的指定坐標(x,y),可以通過以下方式訪問ARGB像素:pixel = rgbArray [offset +(y-startY)* scansize +(x-startX)];
一個
ArrayOutOfBoundsException
,如果該區域不在邊界可能拋出。但是,顯式邊界檢查不能保證。- 參數:
-
startX
- 起始X坐標 -
startY
- 起始Y坐標 -
w
- 區域的寬度 -
h
- 地區的高度 -
rgbArray
- 如果沒有null
,則在這里寫入rgb像素 -
offset
- 抵消了rgbArray
-
scansize
- 掃描線跨度rgbArray
- 返回:
- RGB像素陣列。
- 也可以看看:
-
setRGB(int, int, int)
,setRGB(int, int, int, int, int[], int, int)
-
setRGB
public void setRGB(int x, int y, int rgb)
將其中的像素設置為BufferedImage
指定的RGB值。該像素被假定為默認的RGB顏色模型,TYPE_INT_ARGB和默認的sRGB顏色空間。對於具有an的圖像,IndexColorModel
選擇具有最接近顏色的索引。ArrayOutOfBoundsException
如果坐標不在邊界內,則可能拋出 一個。但是,顯式邊界檢查不能保證。- 參數:
-
x
- 要設置的像素的X坐標 -
y
- 要設置的像素的Y坐標 -
rgb
- RGB值 - 也可以看看:
-
getRGB(int, int)
,getRGB(int, int, int, int, int[], int, int)
-
setRGB
public void setRGB(int startX, int startY, int w, int h, int [] rgbArray, int偏移量, int scansize)
將默認RGB顏色模型(TYPE_INT_ARGB)和默認sRGB顏色空間中的整數像素數組設置為圖像數據的一部分。如果默認模型與圖像不匹配,則會發生顏色轉換ColorModel
。使用此方法時,返回數據中的每個顏色分量只有8位精度。使用此圖像中的指定坐標(x,y),可以通過以下方式訪問ARGB像素:pixel = rgbArray [offset +(y-startY)* scansize +(x-startX)];
警告:不會發生抖動。一個
ArrayOutOfBoundsException
,如果該區域不在邊界可能拋出。但是,顯式邊界檢查不能保證。- 參數:
-
startX
- 起始X坐標 -
startY
- 起始Y坐標 -
w
- 區域的寬度 -
h
- 該地區的高度 -
rgbArray
- RGB像素 -
offset
- 抵消了rgbArray
-
scansize
- 掃描線跨度rgbArray
- 也可以看看:
-
getRGB(int, int)
,getRGB(int, int, int, int, int[], int, int)
-
的getWidth
public int getWidth()
返回。的寬度BufferedImage
。- 指定者:
-
getWidth
在界面中RenderedImage
- 返回:
-
這個的寬度
BufferedImage
-
的getHeight
public int getHeight()
返回。的高度BufferedImage
。- 指定者:
-
getHeight
在界面中RenderedImage
- 返回:
-
這個的高度
BufferedImage
-
的getWidth
public int getWidth(ImageObserver 觀察者)
返回。的寬度BufferedImage
。- 指定者:
-
getWidth
在班上Image
- 參數:
-
observer
- 被忽略 - 返回:
-
這個的寬度
BufferedImage
- 也可以看看:
-
Image.getHeight(java.awt.image.ImageObserver)
,ImageObserver
-
的getHeight
public int getHeight(ImageObserver 觀察者)
返回。的高度BufferedImage
。- 指定者:
-
getHeight
在班上Image
- 參數:
-
observer
- 被忽略 - 返回:
-
這個的高度
BufferedImage
- 也可以看看:
-
Image.getWidth(java.awt.image.ImageObserver)
,ImageObserver
-
的getSource
public ImageProducer getSource()
返回產生圖像像素的對象。- 指定者:
-
getSource
在班上Image
- 返回:
-
的
ImageProducer
是,用於產生像素為這個圖象。 - 也可以看看:
-
ImageProducer
-
的getProperty
public Object getProperty(String name, ImageObserver observer)
按名稱返回圖像的屬性。各個屬性名稱由各種圖像格式定義。如果沒有為特定圖像定義屬性,則此方法返回該UndefinedProperty
字段。如果此圖像的屬性尚未知道,則此方法返回null
並在ImageObserver
稍后通知該對象。應該使用屬性名稱“comment”來存儲可選評論,該評論可以作為圖像,其來源或作者的描述呈現給用戶。- 指定者:
-
getProperty
在班上Image
- 參數:
-
name
- 屬性名稱 -
observer
-ImageObserver
接收有關圖像信息的通知 - 返回:
-
一個
Object
是由指定引用的屬性name
或null
如果這個圖像的性質尚不清楚。 - 拋出:
-
- 如果屬性名稱為空。NullPointerException
- 也可以看看:
-
ImageObserver
,Image.UndefinedProperty
-
的getProperty
public Object getProperty(String name)
按名稱返回圖像的屬性。- 指定者:
-
getProperty
在界面中RenderedImage
- 參數:
-
name
- 屬性名稱 - 返回:
-
一個
Object
是稱為由指定的屬性name
。 - 拋出:
-
- 如果屬性名稱為空。NullPointerException
- 也可以看看:
-
Image.UndefinedProperty
-
的getGraphics
public Graphics getGraphics()
- 指定者:
-
getGraphics
在班上Image
- 返回:
-
a
Graphics2D
,可用於繪制該圖像。 - 也可以看看:
-
Graphics
,Component.createImage(int, int)
-
的createGraphics
public Graphics2D createGraphics()
創建一個Graphics2D
,可以用來繪制這個BufferedImage
。- 返回:
-
一個
Graphics2D
,用於繪制到這個圖像。
-
getSubimage
public BufferedImage getSubimage(int x, int y, int w, int h)
返回由指定的矩形區域定義的子圖像。返回的BufferedImage
共享與原始圖像具有相同的數據陣列。- 參數:
-
x
- 指定矩形區域左上角的X坐標 -
y
- 指定矩形區域左上角的Y坐標 -
w
- 指定的矩形區域的寬度 -
h
- 指定的矩形區域的高度 - 返回:
-
一個
BufferedImage
是這個子圖像BufferedImage
。 - 拋出:
-
- 如果指定的區域不包含在此范圍內RasterFormatException
BufferedImage
。
-
值isAlphaPremultiplied
public boolean isAlphaPremultiplied()
返回alpha是否已經預乘。false
如果沒有alpha,它會返回。- 返回:
-
true
如果alpha已經預乘;false
除此以外。
-
coerceData
public void coerceData(boolean isAlphaPremultiplied)
強制數據匹配isAlphaPremultiplied
變量中指定的狀態 。它可以將顏色柵格數據乘以或除以alpha,或者如果數據處於正確的狀態,則不做任何事情。- 參數:
-
isAlphaPremultiplied
-true
如果alpha已經預乘;false
除此以外。
-
public String toString()
返回String
此BufferedImage
對象及其值的表示形式 。
-
getSources
public Vector < RenderedImage > getSources()
為此返回一Vector
組RenderedImage
對象,它們是圖像數據的直接來源,而不是這些直接來源的來源BufferedImage
。null
如果BufferedImage
沒有關於其直接來源的信息,則返回此方法。Vector
如果BufferedImage
沒有直接來源,它將返回一個空白。- 指定者:
-
getSources
在界面中RenderedImage
- 返回:
-
一個
Vector
包含此BufferedImage
對象的圖像日期的直接來源,或者null
如果它BufferedImage
沒有關於其直接來源的信息,或者 如果它沒有直接來源,Vector
則為空BufferedImage
。
-
getPropertyNames
public String [] getPropertyNames()
- 指定者:
-
getPropertyNames
在界面中RenderedImage
- 返回:
-
一個
String
包含所有可getProperty(String)
識別的屬性名稱的數組; 或者null
如果沒有識別屬性名稱。
-
getMinX
public int getMinX()
返回此的最小x坐標BufferedImage
。這總是零。- 指定者:
-
getMinX
在界面中RenderedImage
- 返回:
-
這個的最小x坐標
BufferedImage
。
-
getMinY
public int getMinY()
返回此的最小y坐標BufferedImage
。這總是零。- 指定者:
-
getMinY
在界面中RenderedImage
- 返回:
-
這個的最小y坐標
BufferedImage
。
-
getSampleModel
public SampleModel getSampleModel()
返回SampleModel
與此關聯的內容BufferedImage
。- 指定者:
-
getSampleModel
在界面中RenderedImage
- 返回:
-
在
SampleModel
這BufferedImage
。
-
getNumXTiles
public int getNumXTiles()
返回x方向上的圖塊數量。這永遠是一個。- 指定者:
-
getNumXTiles
在界面中RenderedImage
- 返回:
- x方向上的瓦片數量。
-
getNumYTiles
public int getNumYTiles()
返回y方向上的圖塊數量。這永遠是一個。- 指定者:
-
getNumYTiles
在界面中RenderedImage
- 返回:
- y方向上的瓦片數量。
-
getMinTileX
public int getMinTileX()
返回x方向上的最小圖塊索引。這總是零。- 指定者:
-
getMinTileX
在界面中RenderedImage
- 返回:
- x方向上的最小瓦片索引。
-
getMinTileY
public int getMinTileY()
返回y方向上的最小圖塊索引。這總是零。- 指定者:
-
getMinTileY
在界面中RenderedImage
- 返回:
- y方向的最小瓦片索引。
-
getTileWidth
public int getTileWidth()
以像素為單位返回圖塊寬度。- 指定者:
-
getTileWidth
在界面中RenderedImage
- 返回:
- 瓦片寬度以像素為單位。
-
getTileHeight
public int getTileHeight()
以像素為單位返回平鋪高度。- 指定者:
-
getTileHeight
在界面中RenderedImage
- 返回:
- 瓷磚高度以像素為單位。
-
getTileGridXOffset
public int getTileGridXOffset()
返回平鋪網格相對於原點的x偏移量,例如平鋪(0,0)位置的x坐標。這總是零。- 指定者:
-
getTileGridXOffset
在界面中RenderedImage
- 返回:
- 瓦片網格的x偏移量。
-
getTileGridYOffset
public int getTileGridYOffset()
返回tile網格相對於原點的y偏移量,例如tile(0,0)位置的y坐標。這總是零。- 指定者:
-
getTileGridYOffset
在界面中RenderedImage
- 返回:
- tile網格的y偏移量。
-
getTile
公共 柵格 getTile(int tileX, int tileY)
返回平鋪(tileX
,tileY
)。請注意,tileX
並tileY
在索引放入瓦陣列,而不是像素位置。在Raster
返回的是活的,這意味着如果圖像改變,它被更新。- 指定者:
-
getTile
在界面中RenderedImage
- 參數:
-
tileX
- 瓦片數組中所請求瓦片的x索引 -
tileY
- 瓦片陣列中請求的瓦片的y索引 - 返回:
-
一個
Raster
是由參數tileX
和參數定義的圖塊tileY
。 - 拋出:
-
-如果兩個ArrayIndexOutOfBoundsException
tileX
和tileY
不等於0
-
的getData
公共 柵格 getData()
將圖像作為一個大圖塊返回。在Raster
返回的是如果圖像改變時它不會更新的圖像數據的副本。- 指定者:
-
getData
在界面中RenderedImage
- 返回:
-
一個
Raster
是圖像數據的副本。 - 也可以看看:
-
setData(Raster)
-
的getData
公共 柵格 getData(矩形 矩形)
計算並返回一個任意的區域BufferedImage
。在Raster
返回的是圖像數據的副本,如果圖像改變時它不會更新。- 指定者:
-
getData
在界面中RenderedImage
- 參數:
-
rect
-BufferedImage
要返回的區域。 - 返回:
-
一個
Raster
是指定區域的圖像數據的副本BufferedImage
- 也可以看看:
-
setData(Raster)
-
了CopyData
公共 WritableRaster copyData(WritableRaster outRaster)
計算任意的矩形區域BufferedImage
並將其復制到指定的區域WritableRaster
。要計算的區域是從指定的邊界確定的WritableRaster
。指定的WritableRaster
必須具有SampleModel
與此圖像兼容的圖像。如果outRaster
是null
,WritableRaster
創建一個適當的。- 指定者:
-
copyData
在界面中RenderedImage
- 參數:
-
outRaster
- aWritableRaster
保存圖像的返回部分,或null
- 返回:
-
對提供或創建的引用
WritableRaster
。
-
使用setData
public void setData(Raster r)
將圖像的矩形區域設置為指定的內容,Raster
r
假定其位於與坐標軸相同的坐標空間中BufferedImage
。該操作被剪切到邊界BufferedImage
。- 指定者:
-
setData
在界面中WritableRenderedImage
- 參數:
-
r
- 指定的Raster
- 也可以看看:
-
getData()
,getData(Rectangle)
-
addTileObserver
public void addTileObserver(TileObserver to)
添加一個tile觀察者。如果觀察者已經存在,它會收到多個通知。- 指定者:
-
addTileObserver
在界面中WritableRenderedImage
- 參數:
-
to
- 指定的TileObserver
-
removeTileObserver
public void removeTileObserver(TileObserver to)
刪除一個tile觀察者。如果觀察員沒有注冊,則沒有任何反應。如果觀察員注冊了多個通知,則現在注冊一個通知。- 指定者:
-
removeTileObserver
在界面中WritableRenderedImage
- 參數:
-
to
- 指定的TileObserver
。
-
isTileWritable
公共布爾isTileWritable(int tileX, int tileY)
返回平鋪當前是否簽出寫入。- 指定者:
-
isTileWritable
在界面中WritableRenderedImage
- 參數:
-
tileX
- 瓦片的x索引。 -
tileY
- 瓦片的y索引。 - 返回:
-
true
如果由指定索引指定的圖塊檢出寫入;false
除此以外。 - 拋出:
-
-如果兩個ArrayIndexOutOfBoundsException
tileX
和tileY
不等於0
-
getWritableTileIndices
public Point [] getWritableTileIndices()
- 指定者:
-
getWritableTileIndices
在界面中WritableRenderedImage
- 返回:
-
一個
Point
數組,用於指示檢出寫入的null
圖塊,或者沒有檢出圖塊進行寫入。
-
hasTileWriters
public boolean hasTileWriters()
返回是否檢出任何圖塊進行寫入。語義上等同於(getWritableTileIndices()!= null)。
- 指定者:
-
hasTileWriters
在界面中WritableRenderedImage
- 返回:
-
true
如果任何磁貼檢出寫入;false
除此以外。
-
getWritableTile
公共 WritableRaster getWritableTile(int tileX, int tileY)
檢查一個瓷磚的寫作。TileObservers
當瓷磚從沒有作家到有一個作家時,所有注冊的 人都會收到通知。- 指定者:
-
getWritableTile
在界面中WritableRenderedImage
- 參數:
-
tileX
- 瓦片的x索引 -
tileY
- 瓦片的y索引 - 返回:
-
一個
WritableRaster
是由指定索引指示的瓦片將被檢出寫入。
-
releaseWritableTile
public void releaseWritableTile(int tileX, int tileY)
放棄寫入瓦片的權限。如果調用者繼續寫入瓦片,結果是不確定的。對此方法的調用應該只會出現在與調用相匹配的對中getWritableTile(int, int)
。任何其他導致未定義的結果。所有注冊的TileObservers
人都會在有一位作家從沒有作家的情況下得到通知。- 指定者:
-
releaseWritableTile
在界面中WritableRenderedImage
- 參數:
-
tileX
- 瓦片的x索引 -
tileY
- 瓦片的y索引
-
getTransparency
public int getTransparency()
返回透明度。返回OPAQUE,BITMASK或TRANSLUCENT。- 指定者:
-
getTransparency
在界面中Transparency
- 返回:
-
這是透明的
BufferedImage
。 - 以來:
- 1.5
- 也可以看看:
-
Transparency.OPAQUE
,Transparency.BITMASK
,Transparency.TRANSLUCENT
-
-