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.
ColorModel, Raster, WritableRaster
| Modifier and Type | Field and Description |
|---|---|
| private ColorModel | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private int | |
| private OffScreenImageSource | |
| private Hashtable | |
| private final WritableRaster | |
| public 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. |
| public 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. |
| public 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. |
| public static final int | TYPE_BYTE_BINARY
Represents an opaque byte-packed 1, 2, or 4 bit image. |
| public static final int | TYPE_BYTE_GRAY
Represents a unsigned byte grayscale image, non-indexed. |
| public static final int | TYPE_BYTE_INDEXED
Represents an indexed byte image. |
| public static final int | TYPE_CUSTOM
Image type is not recognized so it must be a customized image. |
| public static final int | TYPE_INT_ARGB
Represents an image with 8-bit RGBA color components packed into integer pixels. |
| public static final int | TYPE_INT_ARGB_PRE
Represents an image with 8-bit RGBA color components packed into integer pixels. |
| public 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. |
| public static final int | TYPE_INT_RGB
Represents an image with 8-bit RGB color components packed into integer pixels. |
| public 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. |
| public 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. |
| public static final int | TYPE_USHORT_GRAY
Represents an unsigned short grayscale image, non-indexed). |
| Access | Constructor and Description |
|---|---|
| public | BufferedImage(int
width of the created image width, int height of the created image height, int type of the created image imageType)Constructs a |
| public | BufferedImage(int
width of the created image width, int height of the created image height, int type of the created image imageType, IndexColorModel IndexColorModel of the created imageConstructs a |
| public | BufferedImage(ColorModel
ColorModel for the new imageRaster for the image dataif isRasterPremultiplied, Hashtable<?, ?> true, the data in
the raster has been premultiplied with alpha.Hashtable of
String/Object pairs.Constructs a new |
| Modifier and Type | Method and Description |
|---|---|
| public void | addTileObserver(TileObserver
the specified to)TileObserverImplements java. Adds a tile observer. |
| public void | coerceData(boolean
true if the alpha has been
premultiplied; false otherwise.Forces the data to match the state specified in the
|
| public WritableRaster | Returns: a reference to the supplied or createdWritableRaster.a outRaster)WritableRaster to hold the returned
part of the image, or nullImplements java. Computes an arbitrary rectangular region of the
|
| public Graphics2D | Returns: aGraphics2D, used for drawing into this
image.Creates a |
| public WritableRaster | Returns: aWritableRaster or null if this
BufferedImage has no alpha channel associated
with its ColorModel.Returns a |
| public ColorModel | Returns: theColorModel of this
BufferedImage.Implements java. Returns the |
| public Raster | Returns: aRaster that is a copy of the image data.Implements java. Returns the image as one large tile. |
| public Raster | Returns: aRaster that is a copy of the image data of
the specified region of the BufferedImagethe region of the rect)BufferedImage to be
returned.Implements java. Computes and returns an arbitrary region of the
|
| public Graphics | Returns: aGraphics2D, which can be used to draw into
this image.Implements abstract java. This method returns a |
| public int | Returns: the height of thisBufferedImageImplements java. Returns the height of the |
| public int | Returns: the height of thisBufferedImageignored observer)Implements abstract java. Returns the height of the |
| public int | Returns: the minimum tile index in the x direction.Implements java. Returns the minimum tile index in the x direction. |
| public int | Returns: the minimum tile index in the y direction.Implements java. Returns the minimum tile index in the y direction. |
| public int | Returns: the minimum x coordinate of thisBufferedImage.Implements java. Returns the minimum x coordinate of this
|
| public int | Returns: the minimum y coordinate of thisBufferedImage.Implements java. Returns the minimum y coordinate of this
|
| public int | Returns: the number of tiles in the x direction.Implements java. Returns the number of tiles in the x direction. |
| public int | Returns: the number of tiles in the y direction.Implements java. Returns the number of tiles in the y direction. |
| public Object | Returns: anObject that is the property referred to by the
specified name or null if the
properties of this image are not yet known.the property name name, ImageObserver the observer)ImageObserver that receives
notification regarding image informationImplements abstract java. Returns a property of the image by name. |
| public Object | Returns: anObject that is the property referred to by
the specified name.the property name name)Implements java. Returns a property of the image by name. |
| public String[] | Returns: aString array containing all of the property
names that getProperty(String) recognizes;
or null if no property names are recognized.Implements java. Returns an array of names recognized by
|
| public WritableRaster | |
| public int | Returns: an integer pixel in the default RGB color model and default sRGB colorspace.the X coordinate of the pixel from which to get
the pixel in the default RGB color model and sRGB
color space x, int the Y coordinate of the pixel from which to get
the pixel in the default RGB color model and sRGB
color space y)Returns an integer pixel in the default RGB color model (TYPE_INT_ARGB) and default sRGB colorspace. |
| public int[] | Returns: array of RGB pixels.the starting X coordinate startX, int the starting Y coordinate startY, int width of region w, int height of region h, int[] if not rgbArray, int null, the rgb pixels are
written hereoffset into the offset, int rgbArrayscanline stride for the scansize)rgbArrayReturns 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. |
| public SampleModel | Returns: theSampleModel of this
BufferedImage.Implements java. Returns the |
| public ImageProducer | Returns: theImageProducer that is used to produce the
pixels for this image.Implements abstract java. Returns the object that produces the pixels for the image. |
| public Vector | Returns: aVector containing immediate sources of
this BufferedImage object's image date, or
null if this BufferedImage has
no information about its immediate sources, or an empty
Vector if this BufferedImage
has no immediate sources.Implements java. Returns a |
| public BufferedImage | Returns: aBufferedImage that is the subimage of this
BufferedImage.the X coordinate of the upper-left corner of the
specified rectangular region x, int the Y coordinate of the upper-left corner of the
specified rectangular region y, int the width of the specified rectangular region w, int the height of the specified rectangular region h)Returns a subimage defined by a specified rectangular region. |
| public Raster | Returns: aRaster that is the tile defined by the
arguments tileX and tileY.the x index of the requested tile in the tile array tileX, int the y index of the requested tile in the tile array tileY)Implements java. Returns tile ( |
| public int | Returns: the x offset of the tile grid.Implements java. Returns the x offset of the tile grid relative to the origin, For example, the x coordinate of the location of tile (0, 0). |
| public int | Returns: the y offset of the tile grid.Implements java. Returns the y offset of the tile grid relative to the origin, For example, the y coordinate of the location of tile (0, 0). |
| public int | Returns: the tile height in pixels.Implements java. Returns the tile height in pixels. |
| public int | Returns: the tile width in pixels.Implements java. Returns the tile width in pixels. |
| public int | Returns: the transparency of thisBufferedImage.Implements java. Returns the transparency. |
| public int | |
| public int | Returns: the width of thisBufferedImageImplements java. Returns the width of the |
| public int | Returns: the width of thisBufferedImageignored observer)Implements abstract java. Returns the width of the |
| public WritableRaster | Returns: aWritableRaster that is the tile, indicated by
the specified indices, to be checked out for writing.the x index of the tile tileX, int the y index of the tile tileY)Implements java. Checks out a tile for writing. |
| public Point[] | Returns: aPoint array that indicates the tiles that
are checked out for writing, or null if no
tiles are checked out for writing.Implements java. Returns an array of |
| public boolean | Returns: true if any tile is checked out for writing;
false otherwise.Implements java. Returns whether or not any tile is checked out for writing. |
| private static native void | |
| public boolean | Returns: true if the alpha has been premultiplied;
false otherwise.Returns whether or not the alpha has been premultiplied. |
| private static boolean | |
| public boolean | Returns: true if the tile specified by the specified
indices is checked out for writing; false
otherwise.the x index of the tile. tileX, int the y index of the tile. tileY)Implements java. Returns whether or not a tile is currently checked out for writing. |
| public void | releaseWritableTile(int
the x index of the tile tileX, int the y index of the tile tileY)Implements java. Relinquishes permission to write to a tile. |
| public void | removeTileObserver(TileObserver
the specified to)TileObserver.Implements java. Removes a tile observer. |
| public void | setData(Raster
the specified r)RasterImplements java. Sets a rectangular region of the image to the contents of the
specified |
| public void | setRGB(int
the X coordinate of the pixel to set x, int the Y coordinate of the pixel to set y, int the RGB value rgb)Sets a pixel in this |
| public void | setRGB(int
the starting X coordinate startX, int the starting Y coordinate startY, int width of the region w, int height of the region h, int[] the rgb pixels rgbArray, int offset into the offset, int rgbArrayscanline stride for the scansize)rgbArraySets 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. |
| public String | Returns: aString representing this
BufferedImage.Overrides java. Returns a |