Class BufferedImage
- All Implemented Interfaces:
-
RenderedImage,WritableRenderedImage,Transparency
public class BufferedImage extends Image implements WritableRenderedImage, Transparency
BufferedImage subclass describes an Image with an accessible buffer of image data. A BufferedImage is comprised of a ColorModel and a Raster of image data. The number and types of bands in the SampleModel of the Raster must match the number and types required by the ColorModel to represent its color and alpha components. All BufferedImage objects have an upper left corner coordinate of (0, 0). Any Raster used to construct a BufferedImage must therefore have minX=0 and minY=0. This class relies on the data fetching and setting methods of Raster, and on the color characterization methods of ColorModel.
- See Also:
Field Summary
| Modifier and Type | Field | Description |
|---|---|---|
static final int |
TYPE_3BYTE_BGR |
Represents an image with 8-bit RGB color components, corresponding to a Windows-style BGR color model) with the colors Blue, Green, and Red stored in 3 bytes. |
static final int |
TYPE_4BYTE_ABGR |
Represents an image with 8-bit RGBA color components with the colors Blue, Green, and Red stored in 3 bytes and 1 byte of alpha. |
static final int |
TYPE_4BYTE_ABGR_PRE |
Represents an image with 8-bit RGBA color components with the colors Blue, Green, and Red stored in 3 bytes and 1 byte of alpha. |
static final int |
TYPE_BYTE_BINARY |
Represents an opaque byte-packed 1, 2, or 4 bit image. |
static final int |
TYPE_BYTE_GRAY |
Represents a unsigned byte grayscale image, non-indexed. |
static final int |
TYPE_BYTE_INDEXED |
Represents an indexed byte image. |
static final int |
TYPE_CUSTOM |
Image type is not recognized so it must be a customized image. |
static final int |
TYPE_INT_ARGB |
Represents an image with 8-bit RGBA color components packed into integer pixels. |
static final int |
TYPE_INT_ARGB_PRE |
Represents an image with 8-bit RGBA color components packed into integer pixels. |
static final int |
TYPE_INT_BGR |
Represents an image with 8-bit RGB color components, corresponding to a Windows- or Solaris- style BGR color model, with the colors Blue, Green, and Red packed into integer pixels. |
static final int |
TYPE_INT_RGB |
Represents an image with 8-bit RGB color components packed into integer pixels. |
static final int |
TYPE_USHORT_555_RGB |
Represents an image with 5-5-5 RGB color components (5-bits red, 5-bits green, 5-bits blue) with no alpha. |
static final int |
TYPE_USHORT_565_RGB |
Represents an image with 5-6-5 RGB color components (5-bits red, 6-bits green, 5-bits blue) with no alpha. |
static final int |
TYPE_USHORT_GRAY |
Represents an unsigned short grayscale image, non-indexed). |
Fields declared in class java.awt.Image
accelerationPriority, SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedProperty
Fields declared in interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
Constructor Summary
| Constructor | Description |
|---|---|
BufferedImage |
Constructs a BufferedImage of one of the predefined image types. |
BufferedImage |
Constructs a BufferedImage of one of the predefined image types: TYPE_BYTE_BINARY or TYPE_BYTE_INDEXED. |
BufferedImage |
Constructs a new BufferedImage with a specified ColorModel and Raster. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
void |
addTileObserver |
Adds a tile observer. |
void |
coerceData |
Forces the data to match the state specified in the isAlphaPremultiplied variable. |
WritableRaster |
copyData |
Computes an arbitrary rectangular region of the BufferedImage and copies it into a specified WritableRaster. |
Graphics2D |
createGraphics() |
Creates a Graphics2D, which can be used to draw into this BufferedImage. |
WritableRaster |
getAlphaRaster() |
Returns a WritableRaster representing the alpha channel for BufferedImage objects with ColorModel objects that support a separate spatial alpha channel, such as ComponentColorModel and DirectColorModel. |
ColorModel |
getColorModel() |
Returns the ColorModel. |
Raster |
getData() |
Returns the image as one large tile. |
Raster |
getData |
Computes and returns an arbitrary region of the BufferedImage. |
Graphics |
getGraphics() |
This method returns a Graphics2D, but is here for backwards compatibility. |
int |
getHeight() |
Returns the height of the BufferedImage. |
int |
getHeight |
Returns the height of the BufferedImage. |
int |
getMinTileX() |
Returns the minimum tile index in the x direction. |
int |
getMinTileY() |
Returns the minimum tile index in the y direction. |
int |
getMinX() |
Returns the minimum x coordinate of this BufferedImage. |
int |
getMinY() |
Returns the minimum y coordinate of this BufferedImage. |
int |
getNumXTiles() |
Returns the number of tiles in the x direction. |
int |
getNumYTiles() |
Returns the number of tiles in the y direction. |
Object |
getProperty |
Returns a property of the image by name. |
Object |
getProperty |
Returns a property of the image by name. |
String[] |
getPropertyNames() |
Returns an array of names recognized by getProperty(String) or null, if no property names are recognized. |
WritableRaster |
getRaster() |
Returns the WritableRaster. |
int |
getRGB |
Returns an integer pixel in the default RGB color model (TYPE_INT_ARGB) and default sRGB colorspace. |
int[] |
getRGB |
Returns an array of integer pixels in the default RGB color model (TYPE_INT_ARGB) and default sRGB color space, from a portion of the image data. |
SampleModel |
getSampleModel() |
Returns the SampleModel associated with this BufferedImage. |
ImageProducer |
getSource() |
Returns the object that produces the pixels for the image. |
Vector<RenderedImage> |
getSources() |
Returns a Vector of RenderedImage objects that are the immediate sources, not the sources of these immediate sources, of image data for this BufferedImage. |
BufferedImage |
getSubimage |
Returns a subimage defined by a specified rectangular region. |
Raster |
getTile |
Returns tile ( tileX, tileY). |
int |
getTileGridXOffset() |
Returns the x offset of the tile grid relative to the origin, For example, the x coordinate of the location of tile (0, 0). |
int |
getTileGridYOffset() |
Returns the y offset of the tile grid relative to the origin, For example, the y coordinate of the location of tile (0, 0). |
int |
getTileHeight() |
Returns the tile height in pixels. |
int |
getTileWidth() |
Returns the tile width in pixels. |
int |
getTransparency() |
Returns the transparency. |
int |
getType() |
Returns the image type. |
int |
getWidth() |
Returns the width of the BufferedImage. |
int |
getWidth |
Returns the width of the BufferedImage. |
WritableRaster |
getWritableTile |
Checks out a tile for writing. |
Point[] |
getWritableTileIndices() |
Returns an array of Point objects indicating which tiles are checked out for writing. |
boolean |
hasTileWriters() |
Returns whether or not any tile is checked out for writing. |
boolean |
isAlphaPremultiplied() |
Returns whether or not the alpha has been premultiplied. |
boolean |
isTileWritable |
Returns whether or not a tile is currently checked out for writing. |
void |
releaseWritableTile |
Relinquishes permission to write to a tile. |
void |
removeTileObserver |
Removes a tile observer. |
void |
setData |
Sets a rectangular region of the image to the contents of the specified Raster r, which is assumed to be in the same coordinate space as the BufferedImage. |
void |
setRGB |
Sets a pixel in this BufferedImage to the specified RGB value. |
void |
setRGB |
Sets an array of integer pixels in the default RGB color model (TYPE_INT_ARGB) and default sRGB color space, into a portion of the image data. |
String |
toString() |
Returns a String representation of this BufferedImage object and its values. |
Methods declared in class java.awt.Image
flush, getAccelerationPriority, getCapabilities, getScaledInstance, setAccelerationPriority
Field Details
TYPE_CUSTOM
public static final int TYPE_CUSTOM
- See Also:
TYPE_INT_RGB
public static final int TYPE_INT_RGB
DirectColorModel without alpha. When data with non-opaque alpha is stored in an image of this type, the color data must be adjusted to a non-premultiplied form and the alpha discarded, as described in the AlphaComposite documentation.- See Also:
TYPE_INT_ARGB
public static final int TYPE_INT_ARGB
DirectColorModel with alpha. The color data in this image is considered not to be premultiplied with alpha. When this type is used as the imageType argument to a BufferedImage constructor, the created image is consistent with images created in the JDK1.1 and earlier releases.- See Also:
TYPE_INT_ARGB_PRE
public static final int TYPE_INT_ARGB_PRE
DirectColorModel with alpha. The color data in this image is considered to be premultiplied with alpha.- See Also:
TYPE_INT_BGR
public static final int TYPE_INT_BGR
DirectColorModel. When data with non-opaque alpha is stored in an image of this type, the color data must be adjusted to a non-premultiplied form and the alpha discarded, as described in the AlphaComposite documentation.- See Also:
TYPE_3BYTE_BGR
public static final int TYPE_3BYTE_BGR
ComponentColorModel. When data with non-opaque alpha is stored in an image of this type, the color data must be adjusted to a non-premultiplied form and the alpha discarded, as described in the AlphaComposite documentation.- See Also:
TYPE_4BYTE_ABGR
public static final int TYPE_4BYTE_ABGR
ComponentColorModel with alpha. The color data in this image is considered not to be premultiplied with alpha. The byte data is interleaved in a single byte array in the order A, B, G, R from lower to higher byte addresses within each pixel.- See Also:
TYPE_4BYTE_ABGR_PRE
public static final int TYPE_4BYTE_ABGR_PRE
ComponentColorModel with alpha. The color data in this image is considered to be premultiplied with alpha. The byte data is interleaved in a single byte array in the order A, B, G, R from lower to higher byte addresses within each pixel.- See Also:
TYPE_USHORT_565_RGB
public static final int TYPE_USHORT_565_RGB
DirectColorModel. When data with non-opaque alpha is stored in an image of this type, the color data must be adjusted to a non-premultiplied form and the alpha discarded, as described in the AlphaComposite documentation.- See Also:
TYPE_USHORT_555_RGB
public static final int TYPE_USHORT_555_RGB
DirectColorModel. When data with non-opaque alpha is stored in an image of this type, the color data must be adjusted to a non-premultiplied form and the alpha discarded, as described in the AlphaComposite documentation.- See Also:
TYPE_BYTE_GRAY
public static final int TYPE_BYTE_GRAY
ComponentColorModel with a CS_GRAY ColorSpace. When data with non-opaque alpha is stored in an image of this type, the color data must be adjusted to a non-premultiplied form and the alpha discarded, as described in the AlphaComposite documentation.- See Also:
TYPE_USHORT_GRAY
public static final int TYPE_USHORT_GRAY
ComponentColorModel with a CS_GRAY ColorSpace. When data with non-opaque alpha is stored in an image of this type, the color data must be adjusted to a non-premultiplied form and the alpha discarded, as described in the AlphaComposite documentation.- See Also:
TYPE_BYTE_BINARY
public static final int TYPE_BYTE_BINARY
IndexColorModel without alpha. When this type is used as the imageType argument to the BufferedImage constructor that takes an imageType argument but no ColorModel argument, a 1-bit image is created with an IndexColorModel with two colors in the default sRGB ColorSpace: {0, 0, 0} and {255, 255, 255}. Images with 2 or 4 bits per pixel may be constructed via the BufferedImage constructor that takes a ColorModel argument by supplying a ColorModel with an appropriate map size.
Images with 8 bits per pixel should use the image types TYPE_BYTE_INDEXED or TYPE_BYTE_GRAY depending on their ColorModel.
When color data is stored in an image of this type, the closest color in the colormap is determined by the IndexColorModel and the resulting index is stored. Approximation and loss of alpha or color components can result, depending on the colors in the IndexColorModel colormap.
- See Also:
TYPE_BYTE_INDEXED
public static final int TYPE_BYTE_INDEXED
imageType argument to the BufferedImage constructor that takes an imageType argument but no ColorModel argument, an IndexColorModel is created with a 256-color 6/6/6 color cube palette with the rest of the colors from 216-255 populated by grayscale values in the default sRGB ColorSpace. When color data is stored in an image of this type, the closest color in the colormap is determined by the IndexColorModel and the resulting index is stored. Approximation and loss of alpha or color components can result, depending on the colors in the IndexColorModel colormap.
- See Also:
Constructor Details
BufferedImage
public BufferedImage(int width, int height, int imageType)
BufferedImage of one of the predefined image types. The ColorSpace for the image is the default sRGB space.- Parameters:
-
width- width of the created image -
height- height of the created image -
imageType- type of the created image - See Also:
BufferedImage
public BufferedImage(int width, int height, int imageType, IndexColorModel cm)
BufferedImage of one of the predefined image types: TYPE_BYTE_BINARY or TYPE_BYTE_INDEXED. If the image type is TYPE_BYTE_BINARY, the number of entries in the color model is used to determine whether the image should have 1, 2, or 4 bits per pixel. If the color model has 1 or 2 entries, the image will have 1 bit per pixel. If it has 3 or 4 entries, the image with have 2 bits per pixel. If it has between 5 and 16 entries, the image will have 4 bits per pixel. Otherwise, an IllegalArgumentException will be thrown.
- Parameters:
-
width- width of the created image -
height- height of the created image -
imageType- type of the created image -
cm-IndexColorModelof the created image - Throws:
-
IllegalArgumentException- if the imageType is not TYPE_BYTE_BINARY or TYPE_BYTE_INDEXED or if the imageType is TYPE_BYTE_BINARY and the color map has more than 16 entries. - See Also:
BufferedImage
public BufferedImage(ColorModel cm, WritableRaster raster, boolean isRasterPremultiplied, Hashtable<?,?> properties)
BufferedImage with a specified ColorModel and Raster. If the number and types of bands in the SampleModel of the Raster do not match the number and types required by the ColorModel to represent its color and alpha components, a RasterFormatException is thrown. This method can multiply or divide the color Raster data by alpha to match the alphaPremultiplied state in the ColorModel. Properties for this BufferedImage can be established by passing in a Hashtable of String/Object pairs.- Parameters:
-
cm-ColorModelfor the new image -
raster-Rasterfor the image data -
isRasterPremultiplied- iftrue, the data in the raster has been premultiplied with alpha. -
properties-HashtableofString/Objectpairs. - Throws:
-
RasterFormatException- if the number and types of bands in theSampleModelof theRasterdo not match the number and types required by theColorModelto represent its color and alpha components. -
IllegalArgumentException- ifrasteris incompatible withcm - See Also:
Method Details
getType
public int getType()
- Returns:
- the image type of this
BufferedImage. - See Also:
getColorModel
public ColorModel getColorModel()
ColorModel.- Specified by:
-
getColorModelin interfaceRenderedImage - Returns:
- the
ColorModelof thisBufferedImage.
getRaster
public WritableRaster getRaster()
WritableRaster.- Returns:
- the
WritableRasterof thisBufferedImage.
getAlphaRaster
public WritableRaster getAlphaRaster()
WritableRaster representing the alpha channel for BufferedImage objects with ColorModel objects that support a separate spatial alpha channel, such as ComponentColorModel and DirectColorModel. Returns null if there is no alpha channel associated with the ColorModel in this image. This method assumes that for all ColorModel objects other than IndexColorModel, if the ColorModel supports alpha, there is a separate alpha channel which is stored as the last band of image data. If the image uses an IndexColorModel that has alpha in the lookup table, this method returns null since there is no spatially discrete alpha channel. This method creates a new WritableRaster, but shares the data array.- Returns:
- a
WritableRasterornullif thisBufferedImagehas no alpha channel associated with itsColorModel.
getRGB
public int getRGB(int x, int y)
ColorModel. There are only 8-bits of precision for each color component in the returned data when using this method. An ArrayOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
- Parameters:
-
x- the X coordinate of the pixel from which to get the pixel in the default RGB color model and sRGB color space -
y- the Y coordinate of the pixel from which to get the pixel in the default RGB color model and sRGB color space - Returns:
- an integer pixel in the default RGB color model and default sRGB colorspace.
- See Also:
getRGB
public int[] getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize)
ColorModel. There are only 8-bits of precision for each color component in the returned data when using this method. With a specified coordinate (x, y) in the image, the ARGB pixel can be accessed in this way:
pixel = rgbArray[offset + (y-startY)*scansize + (x-startX)]; An ArrayOutOfBoundsException may be thrown if the region is not in bounds. However, explicit bounds checking is not guaranteed.
- Parameters:
-
startX- the starting X coordinate -
startY- the starting Y coordinate -
w- width of region -
h- height of region -
rgbArray- if notnull, the rgb pixels are written here -
offset- offset into thergbArray -
scansize- scanline stride for thergbArray - Returns:
- array of RGB pixels.
- See Also:
setRGB
public void setRGB(int x, int y, int rgb)
BufferedImage to the specified RGB value. The pixel is assumed to be in the default RGB color model, TYPE_INT_ARGB, and default sRGB color space. For images with an IndexColorModel, the index with the nearest color is chosen. An ArrayOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.
- Parameters:
-
x- the X coordinate of the pixel to set -
y- the Y coordinate of the pixel to set -
rgb- the RGB value - See Also:
setRGB
public void setRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize)
ColorModel. There are only 8-bits of precision for each color component in the returned data when using this method. With a specified coordinate (x, y) in the this image, the ARGB pixel can be accessed in this way:
pixel = rgbArray[offset + (y-startY)*scansize + (x-startX)];
WARNING: No dithering takes place. An ArrayOutOfBoundsException may be thrown if the region is not in bounds. However, explicit bounds checking is not guaranteed.
- Parameters:
-
startX- the starting X coordinate -
startY- the starting Y coordinate -
w- width of the region -
h- height of the region -
rgbArray- the rgb pixels -
offset- offset into thergbArray -
scansize- scanline stride for thergbArray - See Also:
getWidth
public int getWidth()
BufferedImage.- Specified by:
-
getWidthin interfaceRenderedImage - Returns:
- the width of this
BufferedImage
getHeight
public int getHeight()
BufferedImage.- Specified by:
-
getHeightin interfaceRenderedImage - Returns:
- the height of this
BufferedImage
getWidth
public int getWidth(ImageObserver observer)
BufferedImage.getHeight
public int getHeight(ImageObserver observer)
BufferedImage.getSource
public ImageProducer getSource()
- Specified by:
-
getSourcein classImage - Returns:
- the
ImageProducerthat is used to produce the pixels for this image. - See Also:
getProperty
public Object getProperty(String name, ImageObserver observer)
UndefinedProperty field. If the properties for this image are not yet known, then this method returns null and the ImageObserver object is notified later. The property name "comment" should be used to store an optional comment that can be presented to the user as a description of the image, its source, or its author.- Specified by:
-
getPropertyin classImage - Parameters:
-
name- the property name -
observer- theImageObserverthat receives notification regarding image information - Returns:
- an
Objectthat is the property referred to by the specifiednameornullif the properties of this image are not yet known. - Throws:
-
NullPointerException- if the property name is null. - See Also:
getProperty
public Object getProperty(String name)
- Specified by:
-
getPropertyin interfaceRenderedImage - Parameters:
-
name- the property name - Returns:
- an
Objectthat is the property referred to by the specifiedname. - Throws:
-
NullPointerException- if the property name is null. - See Also:
getGraphics
public Graphics getGraphics()
Graphics2D, but is here for backwards compatibility. createGraphics is more convenient, since it is declared to return a Graphics2D.- Specified by:
-
getGraphicsin classImage - Returns:
- a
Graphics2D, which can be used to draw into this image. - See Also:
createGraphics
public Graphics2D createGraphics()
Graphics2D, which can be used to draw into this BufferedImage.- Returns:
- a
Graphics2D, used for drawing into this image.
getSubimage
public BufferedImage getSubimage(int x, int y, int w, int h)
BufferedImage shares the same data array as the original image.- Parameters:
-
x- the X coordinate of the upper-left corner of the specified rectangular region -
y- the Y coordinate of the upper-left corner of the specified rectangular region -
w- the width of the specified rectangular region -
h- the height of the specified rectangular region - Returns:
- a
BufferedImagethat is the subimage of thisBufferedImage. - Throws:
-
RasterFormatException- if the specified area is not contained within thisBufferedImage.
isAlphaPremultiplied
public boolean isAlphaPremultiplied()
false if there is no alpha.- Returns:
-
trueif the alpha has been premultiplied;falseotherwise.
coerceData
public void coerceData(boolean isAlphaPremultiplied)
isAlphaPremultiplied variable. It may multiply or divide the color raster data by alpha, or do nothing if the data is in the correct state.- Parameters:
-
isAlphaPremultiplied-trueif the alpha has been premultiplied;falseotherwise.
toString
public String toString()
String representation of this BufferedImage object and its values.getSources
public Vector<RenderedImage> getSources()
Vector of RenderedImage objects that are the immediate sources, not the sources of these immediate sources, of image data for this BufferedImage. This method returns null if the BufferedImage has no information about its immediate sources. It returns an empty Vector if the BufferedImage has no immediate sources.- Specified by:
-
getSourcesin interfaceRenderedImage - Returns:
- a
Vectorcontaining immediate sources of thisBufferedImageobject's image date, ornullif thisBufferedImagehas no information about its immediate sources, or an emptyVectorif thisBufferedImagehas no immediate sources.
getPropertyNames
public String[] getPropertyNames()
getProperty(String) or null, if no property names are recognized.- Specified by:
-
getPropertyNamesin interfaceRenderedImage - Returns:
- a
Stringarray containing all of the property names thatgetProperty(String)recognizes; ornullif no property names are recognized.
getMinX
public int getMinX()
BufferedImage. This is always zero.- Specified by:
-
getMinXin interfaceRenderedImage - Returns:
- the minimum x coordinate of this
BufferedImage.
getMinY
public int getMinY()
BufferedImage. This is always zero.- Specified by:
-
getMinYin interfaceRenderedImage - Returns:
- the minimum y coordinate of this
BufferedImage.
getSampleModel
public SampleModel getSampleModel()
SampleModel associated with this BufferedImage.- Specified by:
-
getSampleModelin interfaceRenderedImage - Returns:
- the
SampleModelof thisBufferedImage.
getNumXTiles
public int getNumXTiles()
- Specified by:
-
getNumXTilesin interfaceRenderedImage - Returns:
- the number of tiles in the x direction.
getNumYTiles
public int getNumYTiles()
- Specified by:
-
getNumYTilesin interfaceRenderedImage - Returns:
- the number of tiles in the y direction.
getMinTileX
public int getMinTileX()
- Specified by:
-
getMinTileXin interfaceRenderedImage - Returns:
- the minimum tile index in the x direction.
getMinTileY
public int getMinTileY()
- Specified by:
-
getMinTileYin interfaceRenderedImage - Returns:
- the minimum tile index in the y direction.
getTileWidth
public int getTileWidth()
- Specified by:
-
getTileWidthin interfaceRenderedImage - Returns:
- the tile width in pixels.
getTileHeight
public int getTileHeight()
- Specified by:
-
getTileHeightin interfaceRenderedImage - Returns:
- the tile height in pixels.
getTileGridXOffset
public int getTileGridXOffset()
- Specified by:
-
getTileGridXOffsetin interfaceRenderedImage - Returns:
- the x offset of the tile grid.
getTileGridYOffset
public int getTileGridYOffset()
- Specified by:
-
getTileGridYOffsetin interfaceRenderedImage - Returns:
- the y offset of the tile grid.
getTile
public Raster getTile(int tileX, int tileY)
tileX, tileY). Note that tileX and tileY are indices into the tile array, not pixel locations. The Raster that is returned is live, which means that it is updated if the image is changed.- Specified by:
-
getTilein interfaceRenderedImage - Parameters:
-
tileX- the x index of the requested tile in the tile array -
tileY- the y index of the requested tile in the tile array - Returns:
- a
Rasterthat is the tile defined by the argumentstileXandtileY. - Throws:
-
ArrayIndexOutOfBoundsException- if bothtileXandtileYare not equal to 0
getData
public Raster getData()
Raster returned is a copy of the image data is not updated if the image is changed.- Specified by:
-
getDatain interfaceRenderedImage - Returns:
- a
Rasterthat is a copy of the image data. - See Also:
getData
public Raster getData(Rectangle rect)
BufferedImage. The Raster returned is a copy of the image data and is not updated if the image is changed.- Specified by:
-
getDatain interfaceRenderedImage - Parameters:
-
rect- the region of theBufferedImageto be returned. - Returns:
- a
Rasterthat is a copy of the image data of the specified region of theBufferedImage - See Also:
copyData
public WritableRaster copyData(WritableRaster outRaster)
BufferedImage and copies it into a specified WritableRaster. The region to be computed is determined from the bounds of the specified WritableRaster. The specified WritableRaster must have a SampleModel that is compatible with this image. If outRaster is null, an appropriate WritableRaster is created.- Specified by:
-
copyDatain interfaceRenderedImage - Parameters:
-
outRaster- aWritableRasterto hold the returned part of the image, ornull - Returns:
- a reference to the supplied or created
WritableRaster.
setData
public void setData(Raster r)
Raster r, which is assumed to be in the same coordinate space as the BufferedImage. The operation is clipped to the bounds of the BufferedImage.- Specified by:
-
setDatain interfaceWritableRenderedImage - Parameters:
-
r- the specifiedRaster - See Also:
addTileObserver
public void addTileObserver(TileObserver to)
- Specified by:
-
addTileObserverin interfaceWritableRenderedImage - Parameters:
-
to- the specifiedTileObserver
removeTileObserver
public void removeTileObserver(TileObserver to)
- Specified by:
-
removeTileObserverin interfaceWritableRenderedImage - Parameters:
-
to- the specifiedTileObserver.
isTileWritable
public boolean isTileWritable(int tileX, int tileY)
- Specified by:
-
isTileWritablein interfaceWritableRenderedImage - Parameters:
-
tileX- the x index of the tile. -
tileY- the y index of the tile. - Returns:
-
trueif the tile specified by the specified indices is checked out for writing;falseotherwise. - Throws:
-
ArrayIndexOutOfBoundsException- if bothtileXandtileYare not equal to 0
getWritableTileIndices
public Point[] getWritableTileIndices()
Point objects indicating which tiles are checked out for writing. Returns null if none are checked out.- Specified by:
-
getWritableTileIndicesin interfaceWritableRenderedImage - Returns:
- a
Pointarray that indicates the tiles that are checked out for writing, ornullif no tiles are checked out for writing.
hasTileWriters
public boolean hasTileWriters()
(getWritableTileIndices() != null).
- Specified by:
-
hasTileWritersin interfaceWritableRenderedImage - Returns:
-
trueif any tile is checked out for writing;falseotherwise.
getWritableTile
public WritableRaster getWritableTile(int tileX, int tileY)
TileObservers are notified when a tile goes from having no writers to having one writer.- Specified by:
-
getWritableTilein interfaceWritableRenderedImage - Parameters:
-
tileX- the x index of the tile -
tileY- the y index of the tile - Returns:
- a
WritableRasterthat is the tile, indicated by the specified indices, to be checked out for writing.
releaseWritableTile
public void releaseWritableTile(int tileX, int tileY)
getWritableTile(int, int). Any other leads to undefined results. All registered TileObservers are notified when a tile goes from having one writer to having no writers.- Specified by:
-
releaseWritableTilein interfaceWritableRenderedImage - Parameters:
-
tileX- the x index of the tile -
tileY- the y index of the tile
getTransparency
public int getTransparency()
- Specified by:
-
getTransparencyin interfaceTransparency - Returns:
- the transparency of this
BufferedImage. - Since:
- 1.5
- See Also:
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/java/awt/image/BufferedImage.html