- java.lang.Object
-
- java.awt.Image
-
- java.awt.image.BufferedImage
-
- All Implemented Interfaces:
-
RenderedImage,WritableRenderedImage,Transparency
public class BufferedImage extends Image implements WritableRenderedImage, Transparency
BufferedImage子类描述了具有图像数据可访问缓冲区的Image。 ABufferedImage由ColorModel和Raster的图像数据组成。 Raster的SampleModel中的Raster数量和类型必须与ColorModel要求的数字和类型相匹配,以表示其颜色和Alpha组件。 全部BufferedImage对象的左上角坐标为(0,0)。Raster用于构建BufferedImage任何Raster必须具有minX = 0和minY = 0。这个类依赖的数据获取和设置方法
Raster,并在颜色表征方法ColorModel。- 另请参见:
-
ColorModel,Raster,WritableRaster
-
-
Field Summary
Fields Modifier and Type Field 描述 static intTYPE_3BYTE_BGR表示具有8位RGB颜色分量的图像,对应于Windows风格的BGR颜色模型),蓝色,绿色和红色以3个字节存储。static intTYPE_4BYTE_ABGR表示具有蓝色,绿色和红色的8位RGBA颜色分量的图像,存储在3个字节和1个字节的alpha中。static intTYPE_4BYTE_ABGR_PRE表示具有蓝色,绿色和红色的8位RGBA颜色分量的图像,存储在3个字节和1个字节的alpha中。static intTYPE_BYTE_BINARY表示不透明的字节打包的1,2或4位图像。static intTYPE_BYTE_GRAY表示无符号字节灰度图像,无索引。static intTYPE_BYTE_INDEXED表示索引的字节图像。static intTYPE_CUSTOM图像类型无法识别,因此它必须是自定义图像。static intTYPE_INT_ARGB表示具有8位RGBA颜色成分的整数像素的图像。static intTYPE_INT_ARGB_PRE表示具有8位RGBA颜色成分的整数像素的图像。static intTYPE_INT_BGR表示具有8位RGB颜色分量的图像,对应于Windows或Solaris样式的BGR颜色模型,蓝色,绿色和红色颜色打包成整数像素。static intTYPE_INT_RGB表示具有8位RGB颜色分量的整数像素的图像。static intTYPE_USHORT_555_RGB表示5-5-5 RGB颜色分量(5位红色,5位绿色,5位蓝色)的图像,无alpha。static intTYPE_USHORT_565_RGB表示具有5-6-5 RGB颜色分量(5位红色,6位绿色,5位蓝色),无alpha的图像。static intTYPE_USHORT_GRAY表示无符号短灰度图像,非索引)。-
Fields inherited from class java.awt.Image
accelerationPriority, SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedProperty
-
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
-
-
构造方法摘要
构造方法 Constructor 描述 BufferedImage(int width, int height, int imageType)构造一个预定义的图像类型的BufferedImage。BufferedImage(int width, int height, int imageType, IndexColorModel cm)构造一个预定义的图像类型的一个BufferedImage:TYPE_BYTE_BINARY或TYPE_BYTE_INDEXED。BufferedImage(ColorModel cm, WritableRaster raster, boolean isRasterPremultiplied, Hashtable<?,?> properties)构造一个新的BufferedImage与指定的ColorModel和Raster。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 voidaddTileObserver(TileObserver to)添加瓦片观察器。voidcoerceData(boolean isAlphaPremultiplied)强制数据匹配isAlphaPremultiplied变量中指定的状态。WritableRastercopyData(WritableRaster outRaster)计算BufferedImage的任意矩形区域,并将其复制到指定的WritableRaster。Graphics2DcreateGraphics()创建一个Graphics2D,可以用来绘制这个BufferedImage。WritableRastergetAlphaRaster()返回一个WritableRaster表示BufferedImage对象的alpha通道,其中ColorModel对象支持单独的空间Alpha通道,如ComponentColorModel和DirectColorModel。ColorModelgetColorModel()返回ColorModel。RastergetData()将图像返回为一个大图块。RastergetData(Rectangle rect)计算并返回BufferedImage的任意区域。GraphicsgetGraphics()此方法返回一个Graphics2D,但这里是向后兼容性。intgetHeight()返回BufferedImage的高度。intgetHeight(ImageObserver observer)返回BufferedImage的高度。intgetMinTileX()返回x方向上的最小拼贴索引。intgetMinTileY()返回y方向上的最小瓦片索引。intgetMinX()返回此BufferedImage的最小x坐标。intgetMinY()返回此BufferedImage的最小y坐标。intgetNumXTiles()返回x方向上的图块数。intgetNumYTiles()返回y方向上的图块数。ObjectgetProperty(String name)按名称返回图像的属性。ObjectgetProperty(String name, ImageObserver observer)按名称返回图像的属性。String[]getPropertyNames()如果未识别到属性名称,则返回由getProperty(String)或null识别的名称数组。WritableRastergetRaster()返回WritableRaster。intgetRGB(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颜色空间中的整数像素数组。SampleModelgetSampleModel()返回SampleModel与此相关BufferedImage。ImageProducergetSource()返回产生图像像素的对象。Vector<RenderedImage>getSources()返回Vector的RenderedImage对象是直接来源,而不是这些直接来源的来源,该图像数据的BufferedImage。BufferedImagegetSubimage(int x, int y, int w, int h)返回由指定的矩形区域定义的子图像。RastergetTile(int tileX, int tileY)返回瓦(tileX,tileY)。intgetTileGridXOffset()返回瓦片网格相对于原点的x偏移量,例如,tile(0,0)的位置的x坐标。intgetTileGridYOffset()返回瓦片网格相对于原点的y偏移量,例如,tile(0,0)的位置的y坐标。intgetTileHeight()返回瓷砖高度(像素)。intgetTileWidth()返回瓷砖宽度(以像素为单位)intgetTransparency()返回透明度。intgetType()返回图像类型。intgetWidth()返回BufferedImage的宽度。intgetWidth(ImageObserver observer)返回BufferedImage的宽度。WritableRastergetWritableTile(int tileX, int tileY)检查一个瓦片写作。Point[]getWritableTileIndices()返回一个Point个对象的数组,指示哪些图块被签出用于写入。booleanhasTileWriters()返回是否检出任何图块以进行写入。booleanisAlphaPremultiplied()返回alpha是否被预乘。booleanisTileWritable(int tileX, int tileY)返回是否当前签出拼贴以进行书写。voidreleaseWritableTile(int tileX, int tileY)放弃写入瓦片的权限。voidremoveTileObserver(TileObserver to)移除瓦片观察者。voidsetData(Raster r)将图像的矩形区域设置为指定的Raster r的内容,假定它与BufferedImage在同一坐标空间中。voidsetRGB(int x, int y, int rgb)将此BufferedImage的像素设置为指定的RGB值。voidsetRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize)将默认RGB颜色模型(TYPE_INT_ARGB)和默认sRGB颜色空间中的整数像素数组设置为图像数据的一部分。StringtoString()返回此BufferedImage对象及其值的String表示。-
Methods inherited from class java.awt.Image
flush, getAccelerationPriority, getCapabilities, getScaledInstance, setAccelerationPriority
-
-
-
-
字段详细信息
-
TYPE_CUSTOM
public static final int TYPE_CUSTOM
图像类型无法识别,因此它必须是自定义图像。 此类型仅用作getType()方法的返回值。- 另请参见:
- Constant Field Values
-
TYPE_INT_RGB
public static final int TYPE_INT_RGB
表示具有8位RGB颜色分量的整数像素的图像。 该图像有一个DirectColorModel没有alpha。 当具有非不透明alpha的数据存储在此类型的图像中时,必须将颜色数据调整为非预乘式格式,并将alpha丢弃,如AlphaComposite文档中所述。- 另请参见:
- Constant Field Values
-
TYPE_INT_ARGB
public static final int TYPE_INT_ARGB
表示具有8位RGBA颜色成分的整数像素的图像。 图像有一个DirectColorModel与alpha。 该图像中的颜色数据被认为不被alpha预付。 当此类型用作BufferedImage构造函数的imageType参数时,创建的映像与JDK1.1及更早版本中创建的映像一致。- 另请参见:
- Constant Field Values
-
TYPE_INT_ARGB_PRE
public static final int TYPE_INT_ARGB_PRE
表示具有8位RGBA颜色成分的整数像素的图像。 该图像有一个DirectColorModel与alpha。 该图像中的颜色数据被认为是用alpha预乘。- 另请参见:
- Constant Field Values
-
TYPE_INT_BGR
public static final int TYPE_INT_BGR
表示具有8位RGB颜色分量的图像,对应于Windows或Solaris样式的BGR颜色模型,蓝色,绿色和红色颜色打包成整数像素。 没有阿尔法 图像有一个DirectColorModel。 当具有非不透明alpha的数据存储在这种类型的图像中时,颜色数据必须调整为非预乘形式,并将alpha丢弃,如AlphaComposite文档中所述。- 另请参见:
- Constant Field Values
-
TYPE_3BYTE_BGR
public static final int TYPE_3BYTE_BGR
表示具有8位RGB颜色分量的图像,对应于Windows风格的BGR颜色模型),蓝色,绿色和红色以3个字节存储。 没有阿尔法 图像有一个ComponentColorModel。 当具有非不透明alpha的数据存储在此类型的图像中时,必须将颜色数据调整为非预乘形式,并将alpha丢弃,如AlphaComposite文档中所述。- 另请参见:
- Constant Field Values
-
TYPE_4BYTE_ABGR
public static final int TYPE_4BYTE_ABGR
表示具有蓝色,绿色和红色的8位RGBA颜色分量的图像,存储在3个字节和1个字节的alpha中。 图像有一个ComponentColorModel与alpha。 该图像中的颜色数据被认为不被alpha预付。 字节数据按照A,B,G,R中的单字节数组交错,从每个像素内的低字节到高字节地址。- 另请参见:
- Constant Field Values
-
TYPE_4BYTE_ABGR_PRE
public static final int TYPE_4BYTE_ABGR_PRE
表示具有蓝色,绿色和红色的8位RGBA颜色分量的图像,存储在3个字节和1个字节的alpha中。 该图像有一个ComponentColorModel与alpha。 该图像中的颜色数据被认为是用alpha预乘。 字节数据按照A,B,G,R中的单字节数组交错,从每个像素内的低字节到高字节地址。- 另请参见:
- Constant Field Values
-
TYPE_USHORT_565_RGB
public static final int TYPE_USHORT_565_RGB
表示具有5-6-5 RGB颜色分量(5位红色,6位绿色,5位蓝色),无alpha的图像。 这张图片有一个DirectColorModel。 当具有非不透明alpha的数据存储在此类型的图像中时,必须将颜色数据调整为非预乘形式,并将alpha丢弃,如AlphaComposite文档中所述。- 另请参见:
- Constant Field Values
-
TYPE_USHORT_555_RGB
public static final int TYPE_USHORT_555_RGB
表示5-5-5 RGB颜色分量(5位红色,5位绿色,5位蓝色)的图像,无alpha。 这张图片有一个DirectColorModel。 当具有非不透明alpha的数据存储在此类型的图像中时,必须将颜色数据调整为非预乘形式,并将alpha丢弃,如AlphaComposite文档中所述。- 另请参见:
- Constant Field Values
-
TYPE_BYTE_GRAY
public static final int TYPE_BYTE_GRAY
表示无符号字节灰度图像,无索引。 这张图片有一个ComponentColorModel与CS_GRAYColorSpace。 当具有非不透明alpha的数据存储在此类型的图像中时,必须将颜色数据调整为非预乘形式并丢弃alpha,如AlphaComposite文档中所述。- 另请参见:
- Constant Field Values
-
TYPE_USHORT_GRAY
public static final int TYPE_USHORT_GRAY
表示无符号短灰度图像,非索引)。 这张图片有一个ComponentColorModel与CS_GRAYColorSpace。 当具有非不透明alpha的数据存储在此类型的图像中时,必须将颜色数据调整为非预乘形式,并将alpha丢弃,如AlphaComposite文档中所述。- 另请参见:
- Constant Field Values
-
TYPE_BYTE_BINARY
public static final int TYPE_BYTE_BINARY
表示不透明的字节打包的1,2或4位图像。 该图像有一个IndexColorModel没有alpha。 当此类型用作BufferedImage构造函数的imageType参数,该参数为imageType参数但不ColorModel参数时,将使用默认sRGBColorSpace中的两个颜色的IndexColorModel创建1位图像:{0,0,0 {255,255,255}。可以通过
BufferedImage构造函数构建具有2或4位像素的图像,通过提供ColorModel具有适当的地图大小来获取ColorModel参数。每像素8位的图像应使用图像类型
TYPE_BYTE_INDEXED或TYPE_BYTE_GRAY具体取决于它们的ColorModel。当颜色数据存储在这种类型的图像中时,色彩映射中最接近的颜色由
IndexColorModel确定,并且存储结果索引。 根据IndexColorModel色彩中的颜色,可能会导致Alpha或颜色成分的近似和损失。- 另请参见:
- Constant Field Values
-
TYPE_BYTE_INDEXED
public static final int TYPE_BYTE_INDEXED
表示索引的字节图像。 当这种类型的被用作imageType参数传递给BufferedImage构造函数的imageType参数,但没有ColorModel参数,一个IndexColorModel与和颜色从216-255其余部分的256色6/6/6颜色立方体调色板创建在默认sRGB ColorSpace中由灰度值填充。当颜色数据存储在这种类型的图像中时,色彩映射中最近的颜色由
IndexColorModel确定,并且生成的索引被存储。 根据IndexColorModel色彩中的颜色,可能会导致近似和损失的alpha或颜色成分。- 另请参见:
- Constant Field Values
-
-
构造方法详细信息
-
BufferedImage
public BufferedImage(int width, int height, 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 height, 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
public BufferedImage(ColorModel cm, WritableRaster raster, boolean isRasterPremultiplied, Hashtable<?,?> properties)
构造一个新的BufferedImage与指定的ColorModel和Raster。 如果带在数量和类型SampleModel所述的Raster不匹配的数量和由所要求的类型ColorModel表示其颜色和alpha分量,一个RasterFormatException被抛出。 这种方法可以乘或除的颜色Raster通过阿尔法数据到匹配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。- Specified by:
-
getColorModel在接口RenderedImage - 结果
-
这
ColorModel的BufferedImage。
-
getRaster
public WritableRaster getRaster()
返回WritableRaster。- 结果
-
这
WritableRaster的BufferedImage。
-
getAlphaRaster
public WritableRaster getAlphaRaster()
返回一个WritableRaster表示BufferedImage对象的alpha通道,其中ColorModel对象支持单独的空间alpha通道,如ComponentColorModel和DirectColorModel。 如果没有与此图像中的ColorModel相关联的Alpha通道,则返回null。 此方法假设所有ColorModel比其他对象IndexColorModel,如果ColorModel支持alpha,存在被存储为图像数据的最后一个频带的单独alpha通道。 如果图像在查找表中使用了一个IndexColorModel,该方法返回null因为没有空间上离散的alpha通道。 此方法创建一个新的WritableRaster,但共享数据数组。- 结果
-
一个
WritableRaster或null如果这BufferedImage没有alpha通道与其ColorModel相关联。
-
getRGB
public int getRGB(int x, int y)返回默认RGB颜色模型(TYPE_INT_ARGB)和默认sRGB颜色空间中的整数像素。 如果此默认模型与图像ColorModel不匹配,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 offset, int scansize)从图像数据的一部分返回默认RGB颜色模型(TYPE_INT_ARGB)和默认sRGB颜色空间中的整数像素数组。 如果默认型号与图像ColorModel不匹配,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颜色空间。 对于具有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 offset, int scansize)将默认RGB颜色模型(TYPE_INT_ARGB)和默认sRGB颜色空间中的整数像素数组设置为图像数据的一部分。 如果默认型号与图像ColorModel不匹配,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的宽度。- Specified by:
-
getWidth在接口RenderedImage - 结果
-
该宽度为
BufferedImage
-
getHeight
public int getHeight()
返回BufferedImage的高度。- Specified by:
-
getHeight在接口RenderedImage - 结果
-
这个高度这
BufferedImage
-
getWidth
public int getWidth(ImageObserver observer)
返回BufferedImage的宽度。- Specified by:
-
getWidth在Image - 参数
-
observer- 忽略 - 结果
-
该宽度为
BufferedImage - 另请参见:
-
Image.getHeight(java.awt.image.ImageObserver),ImageObserver
-
getHeight
public int getHeight(ImageObserver observer)
返回BufferedImage的高度。- Specified by:
-
getHeight在Image - 参数
-
observer- 忽略 - 结果
-
的高度这
BufferedImage - 另请参见:
-
Image.getWidth(java.awt.image.ImageObserver),ImageObserver
-
getSource
public ImageProducer getSource()
返回产生图像像素的对象。- Specified by:
-
getSource在Image - 结果
-
用于生成此图像的像素的
ImageProducer。 - 另请参见:
-
ImageProducer
-
getProperty
public Object getProperty(String name, ImageObserver observer)
按名称返回图像的属性。 单个属性名称由各种图像格式定义。 如果未为特定图像定义属性,则此方法返回UndefinedProperty字段。 如果此图像的属性尚未知道,则此方法返回null,稍后通知ImageObserver对象。 应该使用属性名称“comment”来存储一个可选的注释,该注释可以作为图像,其来源或作者的描述呈现给用户。- Specified by:
-
getProperty在Image - 参数
-
name- 属性名称 -
observer- 接收关于图像信息的通知的ImageObserver - 结果
-
一个
Object,如果该图像的属性尚未知道,则是由指定的name或null的属性。 - 异常
-
NullPointerException- 如果属性名称为空。 - 另请参见:
-
ImageObserver,Image.UndefinedProperty
-
getProperty
public Object getProperty(String name)
按名称返回图像的属性。- Specified by:
-
getProperty在接口RenderedImage - 参数
-
name- 属性名称 - 结果
-
一个
Object是由指定的属性指定的name。 - 异常
-
NullPointerException- 如果属性名称为空。 - 另请参见:
-
Image.UndefinedProperty
-
getGraphics
public Graphics getGraphics()
此方法返回一个Graphics2D,但这里是向后兼容性。createGraphics更方便,因为它被宣布返回一个Graphics2D。- Specified by:
-
getGraphics在Image - 结果
-
一个
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是否被预乘。 如果没有alpha,它返回false。- 结果
-
true如果alpha已被预乘; 否则为false。
-
coerceData
public void coerceData(boolean isAlphaPremultiplied)
强制数据匹配isAlphaPremultiplied变量中指定的状态。 它可以将颜色光栅数据乘以或除以alpha,如果数据处于正确状态,则不执行任何操作。- 参数
-
isAlphaPremultiplied-true如果alpha已被预乘, 否则为false。
-
toString
public String toString()
返回此BufferedImage对象及其值的String表示。
-
getSources
public Vector<RenderedImage> getSources()
返回Vector的RenderedImage对象是直接来源,而不是这些直接来源的来源,该图像数据的BufferedImage。 如果BufferedImage没有关于其直接来源的信息,此方法返回null。 如果BufferedImage没有直接的来源,它将返回一个空的Vector。- Specified by:
-
getSources在接口RenderedImage - 结果
-
一个
Vector包含此的直接来源BufferedImage对象的图像的日期,或null如果此BufferedImage没有关于其直接来源,或空信息Vector,如果这BufferedImage没有直接来源。
-
getPropertyNames
public String[] getPropertyNames()
如果未识别到属性名称,则返回由getProperty(String)或null识别的名称数组。- Specified by:
-
getPropertyNames接口RenderedImage - 结果
-
一个包含
getProperty(String)识别的所有属性名称的String数组; 或者如果没有属性名称被识别,null。
-
getMinX
public int getMinX()
返回此BufferedImage的最小x坐标。 这总是为零。- Specified by:
-
getMinX在接口RenderedImage - 结果
-
这个
BufferedImage的最小x坐标。
-
getMinY
public int getMinY()
返回此BufferedImage的最小y坐标。 这总是为零。- Specified by:
-
getMinY在接口RenderedImage - 结果
-
这个
BufferedImage的最小y坐标。
-
getSampleModel
public SampleModel getSampleModel()
返回SampleModel与此相关BufferedImage。- Specified by:
-
getSampleModel在接口RenderedImage - 结果
-
这
SampleModel的BufferedImage。
-
getNumXTiles
public int getNumXTiles()
返回x方向上的图块数。 这总是一个。- Specified by:
-
getNumXTiles在接口RenderedImage - 结果
- 在x方向上的瓦片数量。
-
getNumYTiles
public int getNumYTiles()
返回y方向上的图块数。 这总是一个。- Specified by:
-
getNumYTiles在接口RenderedImage - 结果
- 在y方向上的瓦片数量。
-
getMinTileX
public int getMinTileX()
返回x方向上的最小拼贴索引。 这总是为零。- Specified by:
-
getMinTileX在接口RenderedImage - 结果
- x方向上的最小瓦片索引。
-
getMinTileY
public int getMinTileY()
返回y方向上的最小瓦片索引。 这总是为零。- Specified by:
-
getMinTileY在接口RenderedImage - 结果
- y方向上的最小瓦片指数。
-
getTileWidth
public int getTileWidth()
返回瓷砖宽度(以像素为单位)- Specified by:
-
getTileWidth在接口RenderedImage - 结果
- 瓦片宽度(以像素为单位)
-
getTileHeight
public int getTileHeight()
返回瓷砖高度(像素)。- Specified by:
-
getTileHeight在接口RenderedImage - 结果
- 瓷砖高度以像素为单位。
-
getTileGridXOffset
public int getTileGridXOffset()
返回瓦片网格相对于原点的x偏移量,例如,tile(0,0)的位置的x坐标。 这总是为零。- Specified by:
-
getTileGridXOffset在接口RenderedImage - 结果
- 瓦片网格的x偏移量。
-
getTileGridYOffset
public int getTileGridYOffset()
返回瓦片网格相对于原点的y偏移量,例如,tile(0,0)的位置的y坐标。 这总是为零。- Specified by:
-
getTileGridYOffset在接口RenderedImage - 结果
- 瓦片网格的y偏移量。
-
getTile
public Raster getTile(int tileX, int tileY)
返回瓦(tileX,tileY)。 请注意,tileX和tileY是tile数组中的索引,而不是像素位置。 返回的Raster是活的,这意味着如果图像被更改,它将被更新。- Specified by:
-
getTile接口RenderedImage - 参数
-
tileX- tile数组中所请求的tile的x索引 -
tileY- tile数组中所请求的tile的y索引 - 结果
-
Raster是由参数tileX和tileY定义的瓦片。 - 异常
-
ArrayIndexOutOfBoundsException- 如果tileX和tileY都不等于0
-
getData
public Raster getData()
将图像返回为一个大图块。Raster返回的图像数据的副本如果图像更改则不更新。- Specified by:
-
getData在接口RenderedImage - 结果
-
一个
Raster是图像数据的副本。 - 另请参见:
-
setData(Raster)
-
getData
public Raster getData(Rectangle rect)
计算并返回任意区域的BufferedImage。 返回的Raster是图像数据的副本,如果图像更改,则不会更新。- Specified by:
-
getData接口RenderedImage - 参数
-
rect- 要返回的地区的BufferedImage。 - 结果
-
一个
Raster是Raster的指定区域的图像数据的BufferedImage - 另请参见:
-
setData(Raster)
-
copyData
public WritableRaster copyData(WritableRaster outRaster)
计算BufferedImage的任意矩形区域,并将其复制到指定的WritableRaster。 要计算的区域根据指定的WritableRaster的范围确定。 指定的WritableRaster必须具有与此图像兼容的SampleModel。 如果outRaster是null,则会创建一个合适的WritableRaster。- Specified by:
-
copyData在接口RenderedImage - 参数
-
outRaster- 一个WritableRaster保存图像的返回部分,或null - 结果
-
参考提供或创建的
WritableRaster。
-
setData
public void setData(Raster r)
将图像的矩形区域设置为指定的Raster r的内容,该内容被假定为与BufferedImage相同的坐标空间。 该操作被限制在BufferedImage的范围内。- Specified by:
-
setData在接口WritableRenderedImage - 参数
-
r- 指定的Raster - 另请参见:
-
getData(),getData(Rectangle)
-
addTileObserver
public void addTileObserver(TileObserver to)
添加瓦片观察器。 如果观察者已经存在,它会收到多个通知。- Specified by:
-
addTileObserver在接口WritableRenderedImage - 参数
-
to- 指定的TileObserver
-
removeTileObserver
public void removeTileObserver(TileObserver to)
移除瓦片观察者。 如果观察员没有注册,没有任何反应。 如果观察员注册了多个通知,则现在注册了一个较少的通知。- Specified by:
-
removeTileObserver在接口WritableRenderedImage - 参数
-
to- 指定的TileObserver。
-
isTileWritable
public boolean isTileWritable(int tileX, int tileY)返回是否当前签出拼贴以进行书写。- Specified by:
-
isTileWritable接口WritableRenderedImage - 参数
-
tileX- 图块的x索引。 -
tileY- 瓷砖的y指数。 - 结果
-
true如果指定的索引指定的tile被签出用于写入; 否则为false。 - 异常
-
ArrayIndexOutOfBoundsException- 如果tileX和tileY都不等于0
-
getWritableTileIndices
public Point[] getWritableTileIndices()
返回一个Point个对象的数组,指示哪些图块被签出用于写入。 如果没有签出,则返回null。- Specified by:
-
getWritableTileIndices在接口WritableRenderedImage - 结果
-
一个
Point数组,表示被签出用于书写的null如果没有拼贴被签出写入,null。
-
hasTileWriters
public boolean hasTileWriters()
返回是否检出任何图块以进行写入。 语义上相当于(getWritableTileIndices() != null).- Specified by:
-
hasTileWriters在接口WritableRenderedImage - 结果
-
true如果任何瓦片被签出写入;false否则。
-
getWritableTile
public WritableRaster getWritableTile(int tileX, int tileY)
检查一个瓦片写作。 所有注册的TileObservers在瓦片从没有作家到拥有一位作家时被通知。- Specified by:
-
getWritableTile在接口WritableRenderedImage - 参数
-
tileX- 图块的x索引 -
tileY- 瓷砖的y指数 - 结果
-
一个
WritableRaster是由指定的索引指示的瓦片,用于书面签出。
-
releaseWritableTile
public void releaseWritableTile(int tileX, int tileY)放弃写入瓦片的权限。 如果呼叫者继续写入瓦片,结果是未定义的。 对此方法的调用只能在匹配的对中出现,并且调用getWritableTile(int, int)。 任何其他导致未定义的结果。 当瓦片从一个作家到没有作家时,通知所有注册的TileObservers。- Specified by:
-
releaseWritableTile在接口WritableRenderedImage - 参数
-
tileX- 图块的x索引 -
tileY- 瓷砖的y指数
-
getTransparency
public int getTransparency()
返回透明度。 返回OPAQUE,BITMASK或TRANSLUCENT。- Specified by:
-
getTransparency在接口Transparency - 结果
-
这个透明度这个
BufferedImage。 - 从以下版本开始:
- 1.5
- 另请参见:
-
Transparency.OPAQUE,Transparency.BITMASK,Transparency.TRANSLUCENT
-
-