Interface Image

All Known Implementing Classes:
AWTImage, GDXImage, JFXImage, TeaImage

public interface Image
Describes image data for an image that has been loaded by the renderer. It is not possible to add Image instances directly to the stage. This class represents the image contents, a Sprite can then be used to add an instance of the image to the stage.

Instances of this class can represent either the entire underlying image, or a rectangular region within the source image. This class allows both situations to be used interchangeably.

  • Method Summary

    Modifier and Type
    Method
    Description
    extractRegion(Region subRegion)
    Returns a new Image instance that is based on the same source image, but only contains the specified rectangular region within the source image.
    int
    getAlpha(int x, int y)
    Returns the alpha of a pixel within the image.
    getColor(int x, int y)
    Returns the RGB color value of a pixel within the image.
    default int
     
     
    default int
     
  • Method Details

    • getRegion

      Region getRegion()
    • getWidth

      default int getWidth()
    • getHeight

      default int getHeight()
    • extractRegion

      Image extractRegion(Region subRegion)
      Returns a new Image instance that is based on the same source image, but only contains the specified rectangular region within the source image. If this Image is itself a region, the coordinates in the region parameter will be interpreted relative to this image's region.
      Throws:
      IllegalArgumentException - if region is located partially or entirely outside of this image.
    • getColor

      ColorRGB getColor(int x, int y)
      Returns the RGB color value of a pixel within the image. This does not include the pixel's alpha value even if the image does support transparency. The returned color does not include an alpha channel. The alpha value of transparent or translucent pixels in the image can be obtained using getAlpha(int, int).
      Throws:
      IllegalArgumentException - If the X or Y coordinate is located outside the image bounds.
    • getAlpha

      int getAlpha(int x, int y)
      Returns the alpha of a pixel within the image. The returned value is between 0 (fully transparent) and 100 (fully opaque).
      Throws:
      IllegalArgumentException - If the X or Y coordinate is located outside the image bounds.