java.lang.Object
nl.colorize.multimedialib.renderer.teavm.TeaImage
All Implemented Interfaces:
Image

public class TeaImage extends Object implements Image
Image implementation that is based on an HTML img element. Since all browser images are loaded asynchronously, an instance of this class can refer to either the full image, or to an image that is currently being loaded.
  • Constructor Details

    • TeaImage

      protected TeaImage(nl.colorize.util.Subscribable<org.teavm.jso.dom.html.HTMLImageElement> imagePromise, Region region)
  • Method Details

    • getImageElement

      public Optional<org.teavm.jso.dom.html.HTMLImageElement> getImageElement()
    • isLoaded

      public boolean isLoaded()
    • getRegion

      public Region getRegion()
      Specified by:
      getRegion in interface Image
    • extractRegion

      public TeaImage extractRegion(Region subRegion)
      Description copied from interface: Image
      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.
      Specified by:
      extractRegion in interface Image
    • getColor

      public ColorRGB getColor(int x, int y)
      Description copied from interface: Image
      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 Image.getAlpha(int, int).
      Specified by:
      getColor in interface Image
    • getAlpha

      public int getAlpha(int x, int y)
      Description copied from interface: Image
      Returns the alpha of a pixel within the image. The returned value is between 0 (fully transparent) and 100 (fully opaque).
      Specified by:
      getAlpha in interface Image
    • forParentImage

      public TeaImage forParentImage()
      Returns a TeaImage instance that uses the same <img> element as this instance, but points to the entire image rather than a specific image region.
      Throws:
      IllegalStateException - if the underlying <img> is still loading, and this image therefore is not available yet.
    • isFullImage

      public boolean isFullImage()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getId

      public UUID getId()
    • getImagePromise

      public nl.colorize.util.Subscribable<org.teavm.jso.dom.html.HTMLImageElement> getImagePromise()