# Image (Slick - The 2D Library)
Date: 2013-06-03

## org.newdawn.slick
Class Image

    java.lang.Object
      org.newdawn.slick.Image

All Implemented Interfaces:
  Renderable

Direct Known Subclasses:
  BigImage, SpriteSheet

    public class Image

extends java.lang.Object
implements Renderable

An image loaded from a file and renderable to the canvas

Author:
  kevin

Field Summary
`protected float` `alpha` The alpha to draw the image at
`protected float` `angle` Angle to rotate the image to.
`static int` `BOTTOM_LEFT` The bottom left corner identifier
`static int` `BOTTOM_RIGHT` The bottom right corner identifier
`protected float` `centerX` The x coordinate of the centre of rotation
`protected float` `centerY` The y coordinate of the centre of rotation
`protected Color[]` `corners` The colours for each of the corners
`protected boolean` `destroyed` True if the image has been destroyed
`static int` `FILTER_LINEAR` Use Linear Filtering
`static int` `FILTER_NEAREST` Use Nearest Filtering
`protected static SGL` `GL` The renderer to use for all GL operations
`protected int` `height` The height of the image
`protected boolean` `inited` True if this image's state has been initialised
`protected static Image` `inUse` The sprite sheet currently in use
`protected java.lang.String` `name` A meaningful name provided by the user of the image to tag it
`protected byte[]` `pixelData` A pixelData holding the pixel data if it's been read for this texture
`protected java.lang.String` `ref` The name given for the image
`protected Texture` `texture` The OpenGL texture for this image
`protected float` `textureHeight` The texture coordinate height to use to find our image
`protected float` `textureOffsetX` The x texture offset to use to find our image
`protected float` `textureOffsetY` The y texture offset to use to find our image
`protected float` `textureWidth` The texture coordinate width to use to find our image
`static int` `TOP_LEFT` The top left corner identifier
`static int` `TOP_RIGHT` The top right corner identifier
`protected int` `width` The width of the image

Constructor Summary
`protected` `Image()` Cloning constructor - only used internally.
`protected` `Image(Image other)` Create a texture as a copy of another
`` `Image(ImageData data)` Create an image from a image data source
`` `Image(ImageData data, int f)` Create an image from a image data source.
`` `Image(java.io.InputStream in, java.lang.String ref, boolean flipped)` Create an image based on a file at the specified location
`` `Image(java.io.InputStream in, java.lang.String ref, boolean flipped, int filter)` Create an image based on a file at the specified location
`` `Image(int width, int height)` Create an empty image
`` `Image(int width, int height, int f)` Create an empty image
`` `Image(java.lang.String ref)` Create an image based on a file at the specified location
`` `Image(java.lang.String ref, boolean flipped)` Create an image based on a file at the specified location
`` `Image(java.lang.String ref, boolean flipped, int filter)` Create an image based on a file at the specified location
`` `Image(java.lang.String ref, boolean flipped, int f, Color transparent)` Create an image based on a file at the specified location
`` `Image(java.lang.String ref, Color trans)` Create an image based on a file at the specified location
`` `Image(Texture texture)` Creates an image using the specified texture

Method Summary
`void` `bind()` Bind to the texture of this image
`void` `clampTexture()` Clamp the loaded texture to it's edges
`Image` `copy()` Get a copy of this image.
`void` `destroy()` Destroy the image and release any native resources.
`void` `draw()` Draw this image at the current location
`void` `draw(float x, float y)` Draw this image at the specified location
`void` `draw(float x, float y, Color filter)` Draw this image at the specified location
`void` `draw(float x, float y, float scale)` Draw the image with a given scale
`void` `draw(float x, float y, float scale, Color filter)` Draw the image with a given scale
`void` `draw(float x, float y, float width, float height)` Draw this image at a specified location and size
`void` `draw(float x, float y, float width, float height, Color filter)` Draw this image at a specified location and size
`void` `draw(float x, float y, float srcx, float srcy, float srcx2, float srcy2)` Draw a section of this image at a particular location and scale on the screen
`void` `draw(float x, float y, float x2, float y2, float srcx, float srcy, float srcx2, float srcy2)` Draw a section of this image at a particular location and scale on the screen
`void` `draw(float x, float y, float x2, float y2, float srcx, float srcy, float srcx2, float srcy2, Color filter)` Draw a section of this image at a particular location and scale on the screen
`void` `drawCentered(float x, float y)` Draw the image based on it's center
`void` `drawEmbedded(float x, float y, float width, float height)` Draw this image as part of a collection of images
`void` `drawEmbedded(float x, float y, float x2, float y2, float srcx, float srcy, float srcx2, float srcy2)` Draw a section of this image at a particular location and scale on the screen, while this is image is "in use", i.e.
`void` `drawEmbedded(float x, float y, float x2, float y2, float srcx, float srcy, float srcx2, float srcy2, Color filter)` Draw a section of this image at a particular location and scale on the screen, while this is image is "in use", i.e.
`void` `drawFlash(float x, float y)` Draw this image at a specified location and size in a white silohette
`void` `drawFlash(float x, float y, float width, float height)` Draw this image at a specified location and size as a silohette
`void` `drawFlash(float x, float y, float width, float height, Color col)` Draw this image at a specified location and size as a silohette
`void` `drawSheared(float x, float y, float hshear, float vshear)` Draw this image at a specified location and size
`void` `drawSheared(float x, float y, float hshear, float vshear, Color filter)` Draw this image at a specified location and size
`void` `drawWarped(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)` Draw the image in a warper rectangle.
`void` `endUse()` End the use of this sprite sheet and release the lock.
`void` `ensureInverted()` Make sure the texture cordinates are inverse on the y axis
`void` `flushPixelData()` Flush the current pixel data to force a re-read next update
`float` `getAlpha()` Get the alpha value to use when rendering this image
`float` `getCenterOfRotationX()` Get the x component of the center of rotation of this image
`float` `getCenterOfRotationY()` Get the y component of the center of rotation of this image
`Color` `getColor(int x, int y)` Get the colour of a pixel at a specified location in this image
`int` `getFilter()` Get the OpenGL image filter in use
`Image` `getFlippedCopy(boolean flipHorizontal, boolean flipVertical)` Get a copy image flipped on potentially two axis
`Graphics` `getGraphics()` Get a graphics context that can be used to draw to this image
`int` `getHeight()` Get the height of this image
`java.lang.String` `getName()` Return a meaningful tagging name that has been assigned to this image.
`java.lang.String` `getResourceReference()` Get the reference to the resource this image was loaded from, if any.
`float` `getRotation()` Get the current angle of rotation for this image.
`Image` `getScaledCopy(float scale)` Get a scaled copy of this image with a uniform scale
`Image` `getScaledCopy(int width, int height)` Get a scaled copy of this image
`Image` `getSubImage(int x, int y, int width, int height)` Get a sub-part of this image.
`Texture` `getTexture()` Get the OpenGL texture holding this image
`float` `getTextureHeight()` Get the height in texels into the source texture
`float` `getTextureOffsetX()` Get the x offset in texels into the source texture
`float` `getTextureOffsetY()` Get the y offset in texels into the source texture
`float` `getTextureWidth()` Get the width in texels into the source texture
`int` `getWidth()` Get the width of this image
`protected void` `init()` Initialise internal data
`protected void` `initImpl()` Hook for subclasses to perform initialisation
`boolean` `isDestroyed()` Check if this image has been destroyed
`protected void` `reinit()` Reinitialise internal data
`void` `rotate(float angle)` Add the angle provided to the current rotation.
`void` `setAlpha(float alpha)` Set the alpha value to use when rendering this image
`void` `setCenterOfRotation(float x, float y)` Set the centre of the rotation when applied to this image
`void` `setColor(int corner, float r, float g, float b)` Set the color of the given corner when this image is rendered.
`void` `setColor(int corner, float r, float g, float b, float a)` Set the color of the given corner when this image is rendered.
`void` `setFilter(int f)` Set the image filtering to be used.
`void` `setImageColor(float r, float g, float b)` Set the filter to apply when drawing this image
`void` `setImageColor(float r, float g, float b, float a)` Set the filter to apply when drawing this image
`void` `setName(java.lang.String name)` Give this image a meaningful tagging name.
`void` `setRotation(float angle)` Set the angle to rotate this image to.
`void` `setTexture(Texture texture)` Set the texture used by this image
`void` `startUse()` Start using this sheet.
`java.lang.String` `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### TOP_LEFT

    public static final int TOP_LEFT

  The top left corner identifier

  See Also:
    Constant Field Values

### TOP_RIGHT

    public static final int TOP_RIGHT

  The top right corner identifier

  See Also:
    Constant Field Values

### BOTTOM_RIGHT

    public static final int BOTTOM_RIGHT

  The bottom right corner identifier

  See Also:
    Constant Field Values

### BOTTOM_LEFT

    public static final int BOTTOM_LEFT

  The bottom left corner identifier

  See Also:
    Constant Field Values

### GL

    protected static SGL GL

  The renderer to use for all GL operations

### inUse

    protected static Image inUse

  The sprite sheet currently in use

### FILTER_LINEAR

    public static final int FILTER_LINEAR

  Use Linear Filtering

  See Also:
    Constant Field Values

### FILTER_NEAREST

    public static final int FILTER_NEAREST

  Use Nearest Filtering

  See Also:
    Constant Field Values

### texture

    protected Texture texture

  The OpenGL texture for this image

### width

    protected int width

  The width of the image

### height

    protected int height

  The height of the image

### textureWidth

    protected float textureWidth

  The texture coordinate width to use to find our image

### textureHeight

    protected float textureHeight

  The texture coordinate height to use to find our image

### textureOffsetX

    protected float textureOffsetX

  The x texture offset to use to find our image

### textureOffsetY

    protected float textureOffsetY

  The y texture offset to use to find our image

### angle

    protected float angle

  Angle to rotate the image to.

### alpha

    protected float alpha

  The alpha to draw the image at

### ref

    protected java.lang.String ref

  The name given for the image

### inited

    protected boolean inited

  True if this image's state has been initialised

### pixelData

    protected byte[] pixelData

  A pixelData holding the pixel data if it's been read for this texture

### destroyed

    protected boolean destroyed

  True if the image has been destroyed

### centerX

    protected float centerX

  The x coordinate of the centre of rotation

### centerY

    protected float centerY

  The y coordinate of the centre of rotation

### name

    protected java.lang.String name

  A meaningful name provided by the user of the image to tag it

### corners

    protected Color[] corners

  The colours for each of the corners

Constructor Detail

### Image

    protected Image(Image other)

  Create a texture as a copy of another

  Parameters:
    `other` - The other texture to copy

### Image

    protected Image()

  Cloning constructor - only used internally.

### Image

    public Image(Texture texture)

  Creates an image using the specified texture

  Parameters:
    `texture` - The texture to use

### Image

    public Image(java.lang.String ref)
          throws SlickException

  Create an image based on a file at the specified location

  Parameters:
    `ref` - The location of the image file to load
  Throws:
    `SlickException` - Indicates a failure to load the image

### Image

    public Image(java.lang.String ref,
                 Color trans)
          throws SlickException

  Create an image based on a file at the specified location

  Parameters:
    `ref` - The location of the image file to load
    `trans` - The color to be treated as transparent
  Throws:
    `SlickException` - Indicates a failure to load the image

### Image

    public Image(java.lang.String ref,
                 boolean flipped)
          throws SlickException

  Create an image based on a file at the specified location

  Parameters:
    `ref` - The location of the image file to load
    `flipped` - True if the image should be flipped on the y-axis on load
  Throws:
    `SlickException` - Indicates a failure to load the image

### Image

    public Image(java.lang.String ref,
                 boolean flipped,
                 int filter)
          throws SlickException

  Create an image based on a file at the specified location

  Parameters:
    `ref` - The location of the image file to load
    `flipped` - True if the image should be flipped on the y-axis on load
    `filter` - The filtering method to use when scaling this image
  Throws:
    `SlickException` - Indicates a failure to load the image

### Image

    public Image(java.lang.String ref,
                 boolean flipped,
                 int f,
                 Color transparent)
          throws SlickException

  Create an image based on a file at the specified location

  Parameters:
    `ref` - The location of the image file to load
    `flipped` - True if the image should be flipped on the y-axis on load
    `f` - The filtering method to use when scaling this image
    `transparent` - The color to treat as transparent
  Throws:
    `SlickException` - Indicates a failure to load the image

### Image

    public Image(int width,
                 int height)
          throws SlickException

  Create an empty image

  Parameters:
    `width` - The width of the image
    `height` - The height of the image
  Throws:
    `SlickException` - Indicates a failure to create the underlying resource

### Image

    public Image(int width,
                 int height,
                 int f)
          throws SlickException

  Create an empty image

  Parameters:
    `width` - The width of the image
    `height` - The height of the image
    `f` - The filter to apply to scaling the new image
  Throws:
    `SlickException` - Indicates a failure to create the underlying resource

### Image

    public Image(java.io.InputStream in,
                 java.lang.String ref,
                 boolean flipped)
          throws SlickException

  Create an image based on a file at the specified location

  Parameters:
    `in` - The input stream to read the image from
    `ref` - The name that should be assigned to the image
    `flipped` - True if the image should be flipped on the y-axis on load
  Throws:
    `SlickException` - Indicates a failure to load the image

### Image

    public Image(java.io.InputStream in,
                 java.lang.String ref,
                 boolean flipped,
                 int filter)
          throws SlickException

  Create an image based on a file at the specified location

  Parameters:
    `in` - The input stream to read the image from
    `ref` - The name that should be assigned to the image
    `flipped` - True if the image should be flipped on the y-axis on load
    `filter` - The filter to use when scaling this image
  Throws:
    `SlickException` - Indicates a failure to load the image

### Image

    public Image(ImageData data)

  Create an image from a image data source

  Parameters:
    `data` - The pixelData to use to create the image

### Image

    public Image(ImageData data,
                 int f)

  Create an image from a image data source. Note that this method uses

  Parameters:
    `data` - The pixelData to use to create the image
    `f` - The filter to use when scaling this image

Method Detail

### setFilter

    public void setFilter(int f)

  Set the image filtering to be used. Note that this will also affect any image that was derived from this one (i.e. sub-images etc)

  Parameters:
    `f` - The filtering mode to use

### getFilter

    public int getFilter()

  Get the OpenGL image filter in use

  Returns:
    The filter for magnification

### getResourceReference

    public java.lang.String getResourceReference()

  Get the reference to the resource this image was loaded from, if any. Note that this can be null in the cases where an image was programatically generated.

  Returns:
    The reference to the resource the reference was loaded from

### setImageColor

    public void setImageColor(float r,
                              float g,
                              float b,
                              float a)

  Set the filter to apply when drawing this image

  Parameters:
    `r` - The red component of the filter colour
    `g` - The green component of the filter colour
    `b` - The blue component of the filter colour
    `a` - The alpha component of the filter colour

### setImageColor

    public void setImageColor(float r,
                              float g,
                              float b)

  Set the filter to apply when drawing this image

  Parameters:
    `r` - The red component of the filter colour
    `g` - The green component of the filter colour
    `b` - The blue component of the filter colour

### setColor

    public void setColor(int corner,
                         float r,
                         float g,
                         float b,
                         float a)

  Set the color of the given corner when this image is rendered. This is useful lots of visual effect but especially light maps

  Parameters:
    `corner` - The corner identifier for the corner to be set
    `r` - The red component value to set (between 0 and 1)
    `g` - The green component value to set (between 0 and 1)
    `b` - The blue component value to set (between 0 and 1)
    `a` - The alpha component value to set (between 0 and 1)

### setColor

    public void setColor(int corner,
                         float r,
                         float g,
                         float b)

  Set the color of the given corner when this image is rendered. This is useful lots of visual effect but especially light maps

  Parameters:
    `corner` - The corner identifier for the corner to be set
    `r` - The red component value to set (between 0 and 1)
    `g` - The green component value to set (between 0 and 1)
    `b` - The blue component value to set (between 0 and 1)

### clampTexture

    public void clampTexture()

  Clamp the loaded texture to it's edges

### setName

    public void setName(java.lang.String name)

  Give this image a meaningful tagging name. Can be used as user data/identifier for the image.

  Parameters:
    `name` - The name to assign the image

### getName

    public java.lang.String getName()

  Return a meaningful tagging name that has been assigned to this image.

  Returns:
    A name or null if the name hasn't been set

### getGraphics

    public Graphics getGraphics()
                         throws SlickException

  Get a graphics context that can be used to draw to this image

  Returns:
    The graphics context used to render to this image
  Throws:
    `SlickException` - Indicates a failure to create a graphics context

### bind

    public void bind()

  Bind to the texture of this image

### reinit

    protected void reinit()

  Reinitialise internal data

### init

    protected final void init()

  Initialise internal data

### initImpl

    protected void initImpl()

  Hook for subclasses to perform initialisation

### draw

    public void draw()

  Draw this image at the current location

### drawCentered

    public void drawCentered(float x,
                             float y)

  Draw the image based on it's center

  Parameters:
    `x` - The x coordinate to place the image's center at
    `y` - The y coordinate to place the image's center at

### draw

    public void draw(float x,
                     float y)

  Draw this image at the specified location

  Specified by:
    `draw` in interface `Renderable`
  Parameters:
    `x` - The x location to draw the image at
    `y` - The y location to draw the image at

### draw

    public void draw(float x,
                     float y,
                     Color filter)

  Draw this image at the specified location

  Parameters:
    `x` - The x location to draw the image at
    `y` - The y location to draw the image at
    `filter` - The color to filter with when drawing

### drawEmbedded

    public void drawEmbedded(float x,
                             float y,
                             float width,
                             float height)

  Draw this image as part of a collection of images

  Parameters:
    `x` - The x location to draw the image at
    `y` - The y location to draw the image at
    `width` - The width to render the image at
    `height` - The height to render the image at

### getTextureOffsetX

    public float getTextureOffsetX()

  Get the x offset in texels into the source texture

  Returns:
    The x offset

### getTextureOffsetY

    public float getTextureOffsetY()

  Get the y offset in texels into the source texture

  Returns:
    The y offset

### getTextureWidth

    public float getTextureWidth()

  Get the width in texels into the source texture

  Returns:
    The width

### getTextureHeight

    public float getTextureHeight()

  Get the height in texels into the source texture

  Returns:
    The height

### draw

    public void draw(float x,
                     float y,
                     float scale)

  Draw the image with a given scale

  Parameters:
    `x` - The x position to draw the image at
    `y` - The y position to draw the image at
    `scale` - The scaling to apply

### draw

    public void draw(float x,
                     float y,
                     float scale,
                     Color filter)

  Draw the image with a given scale

  Parameters:
    `x` - The x position to draw the image at
    `y` - The y position to draw the image at
    `scale` - The scaling to apply
    `filter` - The colour filter to adapt the image with

### draw

    public void draw(float x,
                     float y,
                     float width,
                     float height)

  Draw this image at a specified location and size

  Parameters:
    `x` - The x location to draw the image at
    `y` - The y location to draw the image at
    `width` - The width to render the image at
    `height` - The height to render the image at

### drawSheared

    public void drawSheared(float x,
                            float y,
                            float hshear,
                            float vshear)

  Draw this image at a specified location and size

  Parameters:
    `x` - The x location to draw the image at
    `y` - The y location to draw the image at
    `hshear` - The amount to shear the bottom points by horizontally
    `vshear` - The amount to shear the right points by vertically

### drawSheared

    public void drawSheared(float x,
                            float y,
                            float hshear,
                            float vshear,
                            Color filter)

  Draw this image at a specified location and size

  Parameters:
    `x` - The x location to draw the image at
    `y` - The y location to draw the image at
    `hshear` - The amount to shear the bottom points by horizontally
    `vshear` - The amount to shear the right points by vertically
    `filter` - The colour filter to apply

### draw

    public void draw(float x,
                     float y,
                     float width,
                     float height,
                     Color filter)

  Draw this image at a specified location and size

  Parameters:
    `x` - The x location to draw the image at
    `y` - The y location to draw the image at
    `width` - The width to render the image at
    `height` - The height to render the image at
    `filter` - The color to filter with while drawing

### drawFlash

    public void drawFlash(float x,
                          float y,
                          float width,
                          float height)

  Draw this image at a specified location and size as a silohette

  Parameters:
    `x` - The x location to draw the image at
    `y` - The y location to draw the image at
    `width` - The width to render the image at
    `height` - The height to render the image at

### setCenterOfRotation

    public void setCenterOfRotation(float x,
                                    float y)

  Set the centre of the rotation when applied to this image

  Parameters:
    `x` - The x coordinate of center of rotation relative to the top left corner of the image
    `y` - The y coordinate of center of rotation relative to the top left corner of the image

### getCenterOfRotationX

    public float getCenterOfRotationX()

  Get the x component of the center of rotation of this image

  Returns:
    The x component of the center of rotation

### getCenterOfRotationY

    public float getCenterOfRotationY()

  Get the y component of the center of rotation of this image

  Returns:
    The y component of the center of rotation

### drawFlash

    public void drawFlash(float x,
                          float y,
                          float width,
                          float height,
                          Color col)

  Draw this image at a specified location and size as a silohette

  Parameters:
    `x` - The x location to draw the image at
    `y` - The y location to draw the image at
    `width` - The width to render the image at
    `height` - The height to render the image at
    `col` - The color for the sillohette

### drawFlash

    public void drawFlash(float x,
                          float y)

  Draw this image at a specified location and size in a white silohette

  Parameters:
    `x` - The x location to draw the image at
    `y` - The y location to draw the image at

### setRotation

    public void setRotation(float angle)

  Set the angle to rotate this image to. The angle will be normalized to be 0 <= angle < 360. The image will be rotated around its center.

  Parameters:
    `angle` - The angle to be set

### getRotation

    public float getRotation()

  Get the current angle of rotation for this image. The image will be rotated around its center.

  Returns:
    The current angle.

### getAlpha

    public float getAlpha()

  Get the alpha value to use when rendering this image

  Returns:
    The alpha value to use when rendering this image

### setAlpha

    public void setAlpha(float alpha)

  Set the alpha value to use when rendering this image

  Parameters:
    `alpha` - The alpha value to use when rendering this image

### rotate

    public void rotate(float angle)

  Add the angle provided to the current rotation. The angle will be normalized to be 0 <= angle < 360. The image will be rotated around its center.

  Parameters:
    `angle` - The angle to add.

### getSubImage

    public Image getSubImage(int x,
                             int y,
                             int width,
                             int height)

  Get a sub-part of this image. Note that the create image retains a reference to the image data so should anything change it will affect sub-images too.

  Parameters:
    `x` - The x coordinate of the sub-image
    `y` - The y coordinate of the sub-image
    `width` - The width of the sub-image
    `height` - The height of the sub-image
  Returns:
    The image represent the sub-part of this image

### draw

    public void draw(float x,
                     float y,
                     float srcx,
                     float srcy,
                     float srcx2,
                     float srcy2)

  Draw a section of this image at a particular location and scale on the screen

  Parameters:
    `x` - The x position to draw the image
    `y` - The y position to draw the image
    `srcx` - The x position of the rectangle to draw from this image (i.e. relative to this image)
    `srcy` - The y position of the rectangle to draw from this image (i.e. relative to this image)
    `srcx2` - The x position of the bottom right cornder of rectangle to draw from this image (i.e. relative to this image)
    `srcy2` - The t position of the bottom right cornder of rectangle to draw from this image (i.e. relative to this image)

### draw

    public void draw(float x,
                     float y,
                     float x2,
                     float y2,
                     float srcx,
                     float srcy,
                     float srcx2,
                     float srcy2)

  Draw a section of this image at a particular location and scale on the screen

  Parameters:
    `x` - The x position to draw the image
    `y` - The y position to draw the image
    `x2` - The x position of the bottom right corner of the drawn image
    `y2` - The y position of the bottom right corner of the drawn image
    `srcx` - The x position of the rectangle to draw from this image (i.e. relative to this image)
    `srcy` - The y position of the rectangle to draw from this image (i.e. relative to this image)
    `srcx2` - The x position of the bottom right cornder of rectangle to draw from this image (i.e. relative to this image)
    `srcy2` - The t position of the bottom right cornder of rectangle to draw from this image (i.e. relative to this image)

### draw

    public void draw(float x,
                     float y,
                     float x2,
                     float y2,
                     float srcx,
                     float srcy,
                     float srcx2,
                     float srcy2,
                     Color filter)

  Draw a section of this image at a particular location and scale on the screen

  Parameters:
    `x` - The x position to draw the image
    `y` - The y position to draw the image
    `x2` - The x position of the bottom right corner of the drawn image
    `y2` - The y position of the bottom right corner of the drawn image
    `srcx` - The x position of the rectangle to draw from this image (i.e. relative to this image)
    `srcy` - The y position of the rectangle to draw from this image (i.e. relative to this image)
    `srcx2` - The x position of the bottom right cornder of rectangle to draw from this image (i.e. relative to this image)
    `srcy2` - The t position of the bottom right cornder of rectangle to draw from this image (i.e. relative to this image)
    `filter` - The colour filter to apply when drawing

### drawEmbedded

    public void drawEmbedded(float x,
                             float y,
                             float x2,
                             float y2,
                             float srcx,
                             float srcy,
                             float srcx2,
                             float srcy2)

  Draw a section of this image at a particular location and scale on the screen, while this is image is "in use", i.e. between calls to startUse and endUse.

  Parameters:
    `x` - The x position to draw the image
    `y` - The y position to draw the image
    `x2` - The x position of the bottom right corner of the drawn image
    `y2` - The y position of the bottom right corner of the drawn image
    `srcx` - The x position of the rectangle to draw from this image (i.e. relative to this image)
    `srcy` - The y position of the rectangle to draw from this image (i.e. relative to this image)
    `srcx2` - The x position of the bottom right cornder of rectangle to draw from this image (i.e. relative to this image)
    `srcy2` - The t position of the bottom right cornder of rectangle to draw from this image (i.e. relative to this image)

### drawEmbedded

    public void drawEmbedded(float x,
                             float y,
                             float x2,
                             float y2,
                             float srcx,
                             float srcy,
                             float srcx2,
                             float srcy2,
                             Color filter)

  Draw a section of this image at a particular location and scale on the screen, while this is image is "in use", i.e. between calls to startUse and endUse.

  Parameters:
    `x` - The x position to draw the image
    `y` - The y position to draw the image
    `x2` - The x position of the bottom right corner of the drawn image
    `y2` - The y position of the bottom right corner of the drawn image
    `srcx` - The x position of the rectangle to draw from this image (i.e. relative to this image)
    `srcy` - The y position of the rectangle to draw from this image (i.e. relative to this image)
    `srcx2` - The x position of the bottom right cornder of rectangle to draw from this image (i.e. relative to this image)
    `srcy2` - The t position of the bottom right cornder of rectangle to draw from this image (i.e. relative to this image)
    `filter` - The colour filter to apply when drawing

### drawWarped

    public void drawWarped(float x1,
                           float y1,
                           float x2,
                           float y2,
                           float x3,
                           float y3,
                           float x4,
                           float y4)

  Draw the image in a warper rectangle. The effects this can have are many and varied, might be interesting though.

  Parameters:
    `x1` - The top left corner x coordinate
    `y1` - The top left corner y coordinate
    `x2` - The top right corner x coordinate
    `y2` - The top right corner y coordinate
    `x3` - The bottom right corner x coordinate
    `y3` - The bottom right corner y coordinate
    `x4` - The bottom left corner x coordinate
    `y4` - The bottom left corner y coordinate

### getWidth

    public int getWidth()

  Get the width of this image

  Returns:
    The width of this image

### getHeight

    public int getHeight()

  Get the height of this image

  Returns:
    The height of this image

### copy

    public Image copy()

  Get a copy of this image. This is a shallow copy and does not duplicate image adata.

  Returns:
    The copy of this image

### getScaledCopy

    public Image getScaledCopy(float scale)

  Get a scaled copy of this image with a uniform scale

  Parameters:
    `scale` - The scale to apply
  Returns:
    The new scaled image

### getScaledCopy

    public Image getScaledCopy(int width,
                               int height)

  Get a scaled copy of this image

  Parameters:
    `width` - The width of the copy
    `height` - The height of the copy
  Returns:
    The new scaled image

### ensureInverted

    public void ensureInverted()

  Make sure the texture cordinates are inverse on the y axis

### getFlippedCopy

    public Image getFlippedCopy(boolean flipHorizontal,
                                boolean flipVertical)

  Get a copy image flipped on potentially two axis

  Parameters:
    `flipHorizontal` - True if we want to flip the image horizontally
    `flipVertical` - True if we want to flip the image vertically
  Returns:
    The flipped image instance

### endUse

    public void endUse()

  End the use of this sprite sheet and release the lock.

  See Also:
    `startUse()`

### startUse

    public void startUse()

  Start using this sheet. This method can be used for optimal rendering of a collection of sprites from a single sprite sheet. First, startUse(). Then render each sprite by calling renderInUse(). Finally, endUse(). Between start and end there can be no rendering of other sprites since the rendering is locked for this sprite sheet.

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`
  See Also:
    `Object.toString()`

### getTexture

    public Texture getTexture()

  Get the OpenGL texture holding this image

  Returns:
    The OpenGL texture holding this image

### setTexture

    public void setTexture(Texture texture)

  Set the texture used by this image

  Parameters:
    `texture` - The texture used by this image

### getColor

    public Color getColor(int x,
                          int y)

  Get the colour of a pixel at a specified location in this image

  Parameters:
    `x` - The x coordinate of the pixel
    `y` - The y coordinate of the pixel
  Returns:
    The Color of the pixel at the specified location

### isDestroyed

    public boolean isDestroyed()

  Check if this image has been destroyed

  Returns:
    True if this image has been destroyed

### destroy

    public void destroy()
                 throws SlickException

  Destroy the image and release any native resources. Calls on a destroyed image have undefined results

  Throws:
    `SlickException` - Indicates a failure to release resources on the graphics card

### flushPixelData

    public void flushPixelData()

  Flush the current pixel data to force a re-read next update

Copyright © 2006 New Dawn Software. All Rights Reserved.