Class Image


  extended by Object
      extended by Image

public class Image
extends Object

This class represents loaded image that can be draw to screen. Use Style.image(int) or getImage(String) to obtain image instances.


Constructor Summary
Image(IntArray rgb, int width, int height, boolean processAlpha)
          Creates an immutable image from a sequence of ARGB values, specified as 0xAARRGGBB.
Image(int width, int height)
          Creates new Image that can be modified by acquiring the Graphics and drawing into it.
 
Method Summary
 Graphics getGraphics()
          Returns Graphics object that can be used to draw on this Image.
 Image getRegion(int x, int y, int w, int h)
          Creates a new image from region of this Image.
 void getRGB(IntArray rgbData, int offset, int scanlength, int x, int y, int width, int height)
          Obtains ARGB pixel data from the specified region of this image and stores it in the provided array of integers.
 int height()
          Returns the height of image, in pixels.
 int width()
          Returns the width of image, in pixels.
 
Methods inherited from class Object
toString, equals, hashCode
 
Methods inherited from
equals, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Image

public Image(int width,
             int height)
Creates new Image that can be modified by acquiring the Graphics and drawing into it.

Parameters:
width - Width of created image
height - Height of created image
Since:
2.0.0
See Also:
getGraphics()

Image

public Image(IntArray rgb,
             int width,
             int height,
             boolean processAlpha)
Creates an immutable image from a sequence of ARGB values, specified as 0xAARRGGBB.

Parameters:
rgb - an array of ARGB values that composes the image
width - the width of the image
height - the height of the image
processAlpha - true if rgb has an alpha channel, false if all pixels are fully opaque
Since:
2.0.0
Method Detail

width

public int width()
Returns the width of image, in pixels.

Returns:
width of image

height

public int height()
Returns the height of image, in pixels.

Returns:
height of image

getRegion

public Image getRegion(int x,
                       int y,
                       int w,
                       int h)
Creates a new image from region of this Image. Source rectangle must be within the bounds of image.

Parameters:
x - X-coordinate of top-left corner
y - Y-coordinate of top-left corner
w - Width of region
h - Height of region
Returns:
Region of this image

getGraphics

public Graphics getGraphics()
Returns Graphics object that can be used to draw on this Image. This method can only be called on Images created with Image(int, int) constuctor.

Returns:
Graphics that draws into this Image
Since:
2.0.0

getRGB

public void getRGB(IntArray rgbData,
                   int offset,
                   int scanlength,
                   int x,
                   int y,
                   int width,
                   int height)
Obtains ARGB pixel data from the specified region of this image and stores it in the provided array of integers. Each pixel value is stored in 0xAARRGGBB format, where the high-order byte contains the alpha channel and the remaining bytes contain color components for red, green and blue, respectively. The alpha channel specifies the opacity of the pixel, where a value of 0x00 represents a pixel that is fully transparent and a value of 0xFF represents a fully opaque pixel.

Parameters:
rgbData - an array of integers in which the ARGB pixel data is stored
offset - the index into the array where the first ARGB value is stored
scanlength - the relative offset in the array between corresponding pixels in consecutive rows of the region
x - the x-coordinate of the upper left corner of the region
y - the y-coordinate of the upper left corner of the region
width - the width of the region
height - the height of the region
Since:
2.0.0