java.lang.Object
technology.sola.engine.graphics.Canvas
technology.sola.engine.assets.graphics.SolaImage
All Implemented Interfaces:
Asset

public class SolaImage extends Canvas implements Asset
SolaImage is an Asset that holds pixel data for an image.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The number of cached resizes this image with hold.

    Fields inherited from class technology.sola.engine.graphics.Canvas

    height, pixels, width
  • Constructor Summary

    Constructors
    Constructor
    Description
    SolaImage(int width, int height)
    Creates an empty image with width and height.
    SolaImage(int width, int height, int[] pixels)
    Creates an image from source pixel array.
  • Method Summary

    Modifier and Type
    Method
    Description
    getSubImage(int x, int y, int width, int height)
    Creates a new SolaImage that is a sub-image of this SolaImage.
    resize(int newWidth, int newHeight)
    Resizes this image to a new width and height.
    scale(float scaleX, float scaleY)
    Scales this image by an x-axis and y-axis scale factor.
    void
    setPixels(int width, int height, int[] pixels)
    Manually set the pixel data in this image.

    Methods inherited from class technology.sola.engine.graphics.Canvas

    getHeight, getPixel, getPixel, getPixels, getWidth

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CACHE_SIZE

      public static final int CACHE_SIZE
      The number of cached resizes this image with hold.
      See Also:
  • Constructor Details

    • SolaImage

      public SolaImage(int width, int height)
      Creates an empty image with width and height.
      Parameters:
      width - the width of the image
      height - the height of the image
    • SolaImage

      public SolaImage(int width, int height, int[] pixels)
      Creates an image from source pixel array.
      Parameters:
      width - the width of the image
      height - the height of the image
      pixels - the pixel data for the image
  • Method Details

    • setPixels

      public void setPixels(int width, int height, int[] pixels)
      Manually set the pixel data in this image.
      Parameters:
      width - the width of the image
      height - the height of the image
      pixels - the pixel data for the image
    • getSubImage

      public SolaImage getSubImage(int x, int y, int width, int height)
      Creates a new SolaImage that is a sub-image of this SolaImage.
      Parameters:
      x - the left most coordinate of the sub-image
      y - the top most coordinate of the sub-image
      width - the width of the sub-image
      height - the height of the sub-image
      Returns:
      the sub-image
    • scale

      public SolaImage scale(float scaleX, float scaleY)
      Scales this image by an x-axis and y-axis scale factor. The original image will cache CACHE_SIZE transformations before clearing the cache.
      Parameters:
      scaleX - the x-axis scale factor
      scaleY - the y-axis scale factor
      Returns:
      the scaled image
    • resize

      public SolaImage resize(int newWidth, int newHeight)
      Resizes this image to a new width and height. The original image will cache CACHE_SIZE transformations before clearing the cache.
      Parameters:
      newWidth - the new width
      newHeight - the new height
      Returns:
      the resized image