Class BufferedImage

java.lang.Object
java.awt.Image
java.awt.image.BufferedImage
All Implemented Interfaces:
RenderedImage,WritableRenderedImage,Transparency

public classBufferedImageextendsImageimplementsWritableRenderedImage,Transparency
TheBufferedImage subclass describes anImage with an accessible buffer of image data. ABufferedImage is comprised of aColorModel and aRaster of image data. The number and types of bands in theSampleModel of theRaster must match the number and types required by theColorModel to represent its color and alpha components. AllBufferedImage objects have an upper left corner coordinate of (0, 0). AnyRaster used to construct aBufferedImage must therefore have minX=0 and minY=0.

This class relies on the data fetching and setting methods ofRaster, and on the color characterization methods ofColorModel.

See Also:
  • Field Details

    • TYPE_CUSTOM

      public static final int TYPE_CUSTOM
      Image type is not recognized so it must be a customized image. This type is only used as a return value for the getType() method.
      See Also:
    • TYPE_INT_RGB

      public static final int TYPE_INT_RGB
      Represents an image with 8-bit RGB color components packed into integer pixels. The image has aDirectColorModel 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 theAlphaComposite documentation.
      See Also:
    • TYPE_INT_ARGB

      public static final int TYPE_INT_ARGB
      Represents an image with 8-bit RGBA color components packed into integer pixels. The image has aDirectColorModel with alpha. The color data in this image is considered not to be premultiplied with alpha. When this type is used as theimageType argument to aBufferedImage 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
      Represents an image with 8-bit RGBA color components packed into integer pixels. The image has aDirectColorModel 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
      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. There is no alpha. The image has aDirectColorModel. 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 theAlphaComposite documentation.
      See Also:
    • TYPE_3BYTE_BGR

      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. There is no alpha. The image has aComponentColorModel. 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 theAlphaComposite documentation.
      See Also:
    • TYPE_4BYTE_ABGR

      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. The image has aComponentColorModel 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
      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. The image has aComponentColorModel 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
      Represents an image with 5-6-5 RGB color components (5-bits red, 6-bits green, 5-bits blue) with no alpha. This image has aDirectColorModel. 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 theAlphaComposite documentation.
      See Also:
    • TYPE_USHORT_555_RGB

      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. This image has aDirectColorModel. 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 theAlphaComposite documentation.
      See Also:
    • TYPE_BYTE_GRAY

      public static final int TYPE_BYTE_GRAY
      Represents a unsigned byte grayscale image, non-indexed. This image has aComponentColorModel with a CS_GRAYColorSpace. 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 theAlphaComposite documentation.
      See Also:
    • TYPE_USHORT_GRAY

      public static final int TYPE_USHORT_GRAY
      Represents an unsigned short grayscale image, non-indexed). This image has aComponentColorModel with a CS_GRAYColorSpace. 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 theAlphaComposite documentation.
      See Also:
    • TYPE_BYTE_BINARY

      public static final int TYPE_BYTE_BINARY
      Represents an opaque byte-packed 1, 2, or 4 bit image. The image has anIndexColorModel without alpha. When this type is used as theimageType argument to theBufferedImage constructor that takes animageType argument but noColorModel argument, a 1-bit image is created with anIndexColorModel with two colors in the default sRGBColorSpace: {0, 0, 0} and {255, 255, 255}.

      Images with 2 or 4 bits per pixel may be constructed via theBufferedImage constructor that takes aColorModel argument by supplying aColorModel with an appropriate map size.

      Images with 8 bits per pixel should use the image typesTYPE_BYTE_INDEXED orTYPE_BYTE_GRAY depending on theirColorModel.

      When color data is stored in an image of this type, the closest color in the colormap is determined by theIndexColorModel and the resulting index is stored. Approximation and loss of alpha or color components can result, depending on the colors in theIndexColorModel colormap.

      See Also:
    • TYPE_BYTE_INDEXED

      public static final int TYPE_BYTE_INDEXED
      Represents an indexed byte image. When this type is used as theimageType argument to theBufferedImage constructor that takes animageType argument but noColorModel argument, anIndexColorModel 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 theIndexColorModel and the resulting index is stored. Approximation and loss of alpha or color components can result, depending on the colors in theIndexColorModel colormap.

      See Also:
  • Constructor Details

    • BufferedImage

      public BufferedImage(int width, int height, int imageType)
      Constructs aBufferedImage of one of the predefined image types. TheColorSpace 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)
      Constructs aBufferedImage 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 -IndexColorModel of 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)
      Constructs a newBufferedImage with a specifiedColorModel andRaster. If the number and types of bands in theSampleModel of theRaster do not match the number and types required by theColorModel to represent its color and alpha components, aRasterFormatException is thrown. This method can multiply or divide the colorRaster data by alpha to match thealphaPremultiplied state in theColorModel. Properties for thisBufferedImage can be established by passing in aHashtable ofString/Object pairs.
      Parameters:
      cm -ColorModel for the new image
      raster -Raster for the image data
      isRasterPremultiplied - iftrue, the data in the raster has been premultiplied with alpha.
      properties -Hashtable ofString/Object pairs.
      Throws:
      RasterFormatException - if the number and types of bands in theSampleModel of theRaster do not match the number and types required by theColorModel to represent its color and alpha components.
      IllegalArgumentException - ifraster is incompatible withcm
      See Also:
  • Method Details

    • getType

      public int getType()
      Returns the image type. If it is not one of the known types, TYPE_CUSTOM is returned.
      Returns:
      the image type of thisBufferedImage.
      See Also:
    • getColorModel

      public ColorModel getColorModel()
      Returns theColorModel.
      Specified by:
      getColorModel in interface RenderedImage
      Returns:
      theColorModel of thisBufferedImage.
    • getRaster

      public WritableRaster getRaster()
      Returns theWritableRaster.
      Returns:
      theWritableRaster of thisBufferedImage.
    • getAlphaRaster

      public WritableRaster getAlphaRaster()
      Returns aWritableRaster representing the alpha channel forBufferedImage objects withColorModel objects that support a separate spatial alpha channel, such asComponentColorModel andDirectColorModel. Returnsnull if there is no alpha channel associated with theColorModel in this image. This method assumes that for allColorModel objects other thanIndexColorModel, if theColorModel supports alpha, there is a separate alpha channel which is stored as the last band of image data. If the image uses anIndexColorModel that has alpha in the lookup table, this method returnsnull since there is no spatially discrete alpha channel. This method creates a newWritableRaster, but shares the data array.
      Returns:
      aWritableRaster ornull if thisBufferedImage has no alpha channel associated with itsColorModel.
    • getRGB

      public int getRGB(int x, int y)
      Returns an integer pixel in the default RGB color model (TYPE_INT_ARGB) and default sRGB colorspace. Color conversion takes place if this default model does not match the imageColorModel. There are only 8-bits of precision for each color component in the returned data when using this method.

      AnArrayIndexOutOfBoundsException 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)
      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. Color conversion takes place if the default model does not match the imageColorModel. 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)];

      AnArrayIndexOutOfBoundsException 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)
      Sets a pixel in thisBufferedImage 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 anIndexColorModel, the index with the nearest color is chosen.

      AnArrayIndexOutOfBoundsException 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)
      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. Color conversion takes place if the default model does not match the imageColorModel. 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.

      AnArrayIndexOutOfBoundsException 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()
      Returns the width of theBufferedImage.
      Specified by:
      getWidth in interface RenderedImage
      Returns:
      the width of thisBufferedImage
    • getHeight

      public int getHeight()
      Returns the height of theBufferedImage.
      Specified by:
      getHeight in interface RenderedImage
      Returns:
      the height of thisBufferedImage
    • getWidth

      public int getWidth(ImageObserver observer)
      Returns the width of theBufferedImage.
      Specified by:
      getWidth in class Image
      Parameters:
      observer - ignored
      Returns:
      the width of thisBufferedImage
      See Also:
    • getHeight

      public int getHeight(ImageObserver observer)
      Returns the height of theBufferedImage.
      Specified by:
      getHeight in class Image
      Parameters:
      observer - ignored
      Returns:
      the height of thisBufferedImage
      See Also:
    • getSource

      public ImageProducer getSource()
      Returns the object that produces the pixels for the image.
      Specified by:
      getSource in class Image
      Returns:
      theImageProducer that is used to produce the pixels for this image.
      See Also:
    • getProperty

      public Object getProperty(String name,ImageObserver observer)
      Returns a property of the image by name. Individual property names are defined by the various image formats. If a property is not defined for a particular image, this method returns theUndefinedProperty field. If the properties for this image are not yet known, then this method returnsnull and theImageObserver 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:
      getProperty in class Image
      Parameters:
      name - the property name
      observer - theImageObserver that receives notification regarding image information
      Returns:
      anObject that is the property referred to by the specifiedname ornull if 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)
      Returns a property of the image by name.
      Specified by:
      getProperty in interface RenderedImage
      Parameters:
      name - the property name
      Returns:
      anObject that is the property referred to by the specifiedname.
      Throws:
      NullPointerException - if the property name is null.
      See Also:
    • getGraphics

      public Graphics getGraphics()
      This method returns aGraphics2D, but is here for backwards compatibility.createGraphics is more convenient, since it is declared to return aGraphics2D.
      Specified by:
      getGraphics in class Image
      Returns:
      aGraphics2D, which can be used to draw into this image.
      See Also:
    • createGraphics

      public Graphics2D createGraphics()
      Creates aGraphics2D, which can be used to draw into thisBufferedImage.
      Returns:
      aGraphics2D, used for drawing into this image.
    • getSubimage

      public BufferedImage getSubimage(int x, int y, int w, int h)
      Returns a subimage defined by a specified rectangular region. The returnedBufferedImage 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:
      aBufferedImage that is the subimage of thisBufferedImage.
      Throws:
      RasterFormatException - if the specified area is not contained within thisBufferedImage.
    • isAlphaPremultiplied

      public boolean isAlphaPremultiplied()
      Returns whether or not the alpha has been premultiplied. It returnsfalse if there is no alpha.
      Returns:
      true if the alpha has been premultiplied;false otherwise.
    • coerceData

      public void coerceData(boolean isAlphaPremultiplied)
      Forces the data to match the state specified in theisAlphaPremultiplied 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 -true if the alpha has been premultiplied;false otherwise.
    • toString

      public String toString()
      Returns aString representation of thisBufferedImage object and its values.
      Overrides:
      toString in class Object
      Returns:
      aString representing thisBufferedImage.
    • getSources

      public Vector<RenderedImage> getSources()
      Returns aVector ofRenderedImage objects that are the immediate sources, not the sources of these immediate sources, of image data for thisBufferedImage. This method returnsnull if theBufferedImage has no information about its immediate sources. It returns an emptyVector if theBufferedImage has no immediate sources.
      Specified by:
      getSources in interface RenderedImage
      Returns:
      aVector containing immediate sources of thisBufferedImage object's image date, ornull if thisBufferedImage has no information about its immediate sources, or an emptyVector if thisBufferedImage has no immediate sources.
    • getPropertyNames

      public String[] getPropertyNames()
      Returns an array of names recognized bygetProperty(String) ornull, if no property names are recognized.
      Specified by:
      getPropertyNames in interface RenderedImage
      Returns:
      aString array containing all of the property names thatgetProperty(String) recognizes; ornull if no property names are recognized.
    • getMinX

      public int getMinX()
      Returns the minimum x coordinate of thisBufferedImage. This is always zero.
      Specified by:
      getMinX in interface RenderedImage
      Returns:
      the minimum x coordinate of thisBufferedImage.
    • getMinY

      public int getMinY()
      Returns the minimum y coordinate of thisBufferedImage. This is always zero.
      Specified by:
      getMinY in interface RenderedImage
      Returns:
      the minimum y coordinate of thisBufferedImage.
    • getSampleModel

      public SampleModel getSampleModel()
      Returns theSampleModel associated with thisBufferedImage.
      Specified by:
      getSampleModel in interface RenderedImage
      Returns:
      theSampleModel of thisBufferedImage.
    • getNumXTiles

      public int getNumXTiles()
      Returns the number of tiles in the x direction. This is always one.
      Specified by:
      getNumXTiles in interface RenderedImage
      Returns:
      the number of tiles in the x direction.
    • getNumYTiles

      public int getNumYTiles()
      Returns the number of tiles in the y direction. This is always one.
      Specified by:
      getNumYTiles in interface RenderedImage
      Returns:
      the number of tiles in the y direction.
    • getMinTileX

      public int getMinTileX()
      Returns the minimum tile index in the x direction. This is always zero.
      Specified by:
      getMinTileX in interface RenderedImage
      Returns:
      the minimum tile index in the x direction.
    • getMinTileY

      public int getMinTileY()
      Returns the minimum tile index in the y direction. This is always zero.
      Specified by:
      getMinTileY in interface RenderedImage
      Returns:
      the minimum tile index in the y direction.
    • getTileWidth

      public int getTileWidth()
      Returns the tile width in pixels.
      Specified by:
      getTileWidth in interface RenderedImage
      Returns:
      the tile width in pixels.
    • getTileHeight

      public int getTileHeight()
      Returns the tile height in pixels.
      Specified by:
      getTileHeight in interface RenderedImage
      Returns:
      the tile height in pixels.
    • getTileGridXOffset

      public 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). This is always zero.
      Specified by:
      getTileGridXOffset in interface RenderedImage
      Returns:
      the x offset of the tile grid.
    • getTileGridYOffset

      public 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). This is always zero.
      Specified by:
      getTileGridYOffset in interface RenderedImage
      Returns:
      the y offset of the tile grid.
    • getTile

      public Raster getTile(int tileX, int tileY)
      Returns tile (tileXtileY). Note thattileX andtileY are indices into the tile array, not pixel locations. TheRaster that is returned is live, which means that it is updated if the image is changed.
      Specified by:
      getTile in interface RenderedImage
      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:
      aRaster that is the tile defined by the argumentstileX andtileY.
      Throws:
      ArrayIndexOutOfBoundsException - if bothtileX andtileY are not equal to 0
    • getData

      public Raster getData()
      Returns the image as one large tile. TheRaster returned is a copy of the image data is not updated if the image is changed.
      Specified by:
      getData in interface RenderedImage
      Returns:
      aRaster that is a copy of the image data.
      See Also:
    • getData

      public Raster getData(Rectangle rect)
      Computes and returns an arbitrary region of theBufferedImage. TheRaster returned is a copy of the image data and is not updated if the image is changed.
      Specified by:
      getData in interface RenderedImage
      Parameters:
      rect - the region of theBufferedImage to be returned.
      Returns:
      aRaster that is a copy of the image data of the specified region of theBufferedImage
      See Also:
    • copyData

      public WritableRaster copyData(WritableRaster outRaster)
      Computes an arbitrary rectangular region of theBufferedImage and copies it into a specifiedWritableRaster. The region to be computed is determined from the bounds of the specifiedWritableRaster. The specifiedWritableRaster must have aSampleModel that is compatible with this image. IfoutRaster isnull, an appropriateWritableRaster is created.
      Specified by:
      copyData in interface RenderedImage
      Parameters:
      outRaster - aWritableRaster to hold the returned part of the image, ornull
      Returns:
      a reference to the supplied or createdWritableRaster.
    • setData

      public void setData(Raster r)
      Sets a rectangular region of the image to the contents of the specifiedRaster r, which is assumed to be in the same coordinate space as theBufferedImage. The operation is clipped to the bounds of theBufferedImage.
      Specified by:
      setData in interface WritableRenderedImage
      Parameters:
      r - the specifiedRaster
      See Also:
    • addTileObserver

      public void addTileObserver(TileObserver to)
      Adds a tile observer. If the observer is already present, it receives multiple notifications.

      This method ignores its parameters and does nothing, sinceBufferedImage is always checked out for writing and cannot be made read-only, so there can never be events to dispatch.

      Specified by:
      addTileObserver in interface WritableRenderedImage
      Parameters:
      to - the specifiedTileObserver
    • removeTileObserver

      public void removeTileObserver(TileObserver to)
      Removes a tile observer. If the observer was not registered, nothing happens. If the observer was registered for multiple notifications, it is now registered for one fewer notification.

      This method ignores the given observer, sinceaddTileObserver(TileObserver) adds none.

      Specified by:
      removeTileObserver in interface WritableRenderedImage
      Parameters:
      to - the specifiedTileObserver.
    • isTileWritable

      public boolean isTileWritable(int tileX, int tileY)
      Returns whether or not a tile is currently checked out for writing. The only tile in aBufferedImage is at (0,0) and it is always writable, so calling this method with (0,0) will always returntrue, and any other coordinate will cause an exception to be thrown.
      Specified by:
      isTileWritable in interface WritableRenderedImage
      Parameters:
      tileX - the x index of the tile.
      tileY - the y index of the tile.
      Returns:
      true if the tile specified by the specified indices is checked out for writing;false otherwise.
      Throws:
      IllegalArgumentException - if eithertileX ortileY is not equal to 0
    • getWritableTileIndices

      public Point[] getWritableTileIndices()
      Returns an array ofPoint objects indicating which tiles are checked out for writing. Returnsnull if none are checked out.

      Since aBufferedImage consists of a single tile, and that tile is always checked out for writing, this method returns an array of one point. Further, the offset shall be consistent withgetMinTileX() andgetMinTileY(), which are always (0,0) inBufferedImage. That will always be the coordinates of the single returnedPoint.

      Specified by:
      getWritableTileIndices in interface WritableRenderedImage
      Returns:
      aPoint array that indicates the tiles that are checked out for writing, ornull if no tiles are checked out for writing.
    • hasTileWriters

      public boolean hasTileWriters()
      Returns whether or not any tile is checked out for writing. Semantically equivalent to
       (getWritableTileIndices() != null).
      Specified by:
      hasTileWriters in interface WritableRenderedImage
      Returns:
      true if any tile is checked out for writing;false otherwise.
    • getWritableTile

      public WritableRaster getWritableTile(int tileX, int tileY)
      Checks out a tile for writing. All registeredTileObservers are notified when a tile goes from having no writers to having one writer.

      This method unconditionally returns thesingle tile without checking the passed values. No listeners are notified since the returned tile is always checked out for writing.

      Specified by:
      getWritableTile in interface WritableRenderedImage
      Parameters:
      tileX - the x index of the tile
      tileY - the y index of the tile
      Returns:
      aWritableRaster that is the tile, indicated by the specified indices, to be checked out for writing.
    • releaseWritableTile

      public void releaseWritableTile(int tileX, int tileY)
      Relinquishes permission to write to a tile. If the caller continues to write to the tile, the results are undefined. Calls to this method should only appear in matching pairs with calls togetWritableTile(int, int). Any other leads to undefined results. All registeredTileObservers are notified when a tile goes from having one writer to having no writers.

      This method immediately returns without checking the passed values. No listeners are notified since thesingle tile is always checked out for writing.

      Specified by:
      releaseWritableTile in interface WritableRenderedImage
      Parameters:
      tileX - the x index of the tile
      tileY - the y index of the tile
    • getTransparency

      public int getTransparency()
      Returns the transparency. Returns either OPAQUE, BITMASK, or TRANSLUCENT.
      Specified by:
      getTransparency in interface Transparency
      Returns:
      the transparency of thisBufferedImage.
      Since:
      1.5
      See Also: