|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.newdawn.slick.Image
public class Image
An image loaded from a file and renderable to the canvas
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 |
---|
public static final int TOP_LEFT
public static final int TOP_RIGHT
public static final int BOTTOM_RIGHT
public static final int BOTTOM_LEFT
protected static SGL GL
protected static Image inUse
public static final int FILTER_LINEAR
public static final int FILTER_NEAREST
protected Texture texture
protected int width
protected int height
protected float textureWidth
protected float textureHeight
protected float textureOffsetX
protected float textureOffsetY
protected float angle
protected float alpha
protected java.lang.String ref
protected boolean inited
protected byte[] pixelData
protected boolean destroyed
protected float centerX
protected float centerY
protected java.lang.String name
protected Color[] corners
Constructor Detail |
---|
protected Image(Image other)
other
- The other texture to copyprotected Image()
public Image(Texture texture)
texture
- The texture to usepublic Image(java.lang.String ref) throws SlickException
ref
- The location of the image file to load
SlickException
- Indicates a failure to load the imagepublic Image(java.lang.String ref, Color trans) throws SlickException
ref
- The location of the image file to loadtrans
- The color to be treated as transparent
SlickException
- Indicates a failure to load the imagepublic Image(java.lang.String ref, boolean flipped) throws SlickException
ref
- The location of the image file to loadflipped
- True if the image should be flipped on the y-axis on load
SlickException
- Indicates a failure to load the imagepublic Image(java.lang.String ref, boolean flipped, int filter) throws SlickException
ref
- The location of the image file to loadflipped
- True if the image should be flipped on the y-axis on loadfilter
- The filtering method to use when scaling this image
SlickException
- Indicates a failure to load the imagepublic Image(java.lang.String ref, boolean flipped, int f, Color transparent) throws SlickException
ref
- The location of the image file to loadflipped
- True if the image should be flipped on the y-axis on loadf
- The filtering method to use when scaling this imagetransparent
- The color to treat as transparent
SlickException
- Indicates a failure to load the imagepublic Image(int width, int height) throws SlickException
width
- The width of the imageheight
- The height of the image
SlickException
- Indicates a failure to create the underlying resourcepublic Image(int width, int height, int f) throws SlickException
width
- The width of the imageheight
- The height of the imagef
- The filter to apply to scaling the new image
SlickException
- Indicates a failure to create the underlying resourcepublic Image(java.io.InputStream in, java.lang.String ref, boolean flipped) throws SlickException
in
- The input stream to read the image fromref
- The name that should be assigned to the imageflipped
- True if the image should be flipped on the y-axis on load
SlickException
- Indicates a failure to load the imagepublic Image(java.io.InputStream in, java.lang.String ref, boolean flipped, int filter) throws SlickException
in
- The input stream to read the image fromref
- The name that should be assigned to the imageflipped
- True if the image should be flipped on the y-axis on loadfilter
- The filter to use when scaling this image
SlickException
- Indicates a failure to load the imagepublic Image(ImageData data)
data
- The pixelData to use to create the imagepublic Image(ImageData data, int f)
data
- The pixelData to use to create the imagef
- The filter to use when scaling this imageMethod Detail |
---|
public void setFilter(int f)
f
- The filtering mode to usepublic int getFilter()
public java.lang.String getResourceReference()
public void setImageColor(float r, float g, float b, float a)
r
- The red component of the filter colourg
- The green component of the filter colourb
- The blue component of the filter coloura
- The alpha component of the filter colourpublic void setImageColor(float r, float g, float b)
r
- The red component of the filter colourg
- The green component of the filter colourb
- The blue component of the filter colourpublic void setColor(int corner, float r, float g, float b, float a)
corner
- The corner identifier for the corner to be setr
- 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)public void setColor(int corner, float r, float g, float b)
corner
- The corner identifier for the corner to be setr
- 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)public void clampTexture()
public void setName(java.lang.String name)
name
- The name to assign the imagepublic java.lang.String getName()
public Graphics getGraphics() throws SlickException
SlickException
- Indicates a failure to create a graphics contextpublic void bind()
protected void reinit()
protected final void init()
protected void initImpl()
public void draw()
public void drawCentered(float x, float y)
x
- The x coordinate to place the image's center aty
- The y coordinate to place the image's center atpublic void draw(float x, float y)
draw
in interface Renderable
x
- The x location to draw the image aty
- The y location to draw the image atpublic void draw(float x, float y, Color filter)
x
- The x location to draw the image aty
- The y location to draw the image atfilter
- The color to filter with when drawingpublic void drawEmbedded(float x, float y, float width, float height)
x
- The x location to draw the image aty
- The y location to draw the image atwidth
- The width to render the image atheight
- The height to render the image atpublic float getTextureOffsetX()
public float getTextureOffsetY()
public float getTextureWidth()
public float getTextureHeight()
public void draw(float x, float y, float scale)
x
- The x position to draw the image aty
- The y position to draw the image atscale
- The scaling to applypublic void draw(float x, float y, float scale, Color filter)
x
- The x position to draw the image aty
- The y position to draw the image atscale
- The scaling to applyfilter
- The colour filter to adapt the image withpublic void draw(float x, float y, float width, float height)
x
- The x location to draw the image aty
- The y location to draw the image atwidth
- The width to render the image atheight
- The height to render the image atpublic void drawSheared(float x, float y, float hshear, float vshear)
x
- The x location to draw the image aty
- The y location to draw the image athshear
- The amount to shear the bottom points by horizontallyvshear
- The amount to shear the right points by verticallypublic void drawSheared(float x, float y, float hshear, float vshear, Color filter)
x
- The x location to draw the image aty
- The y location to draw the image athshear
- The amount to shear the bottom points by horizontallyvshear
- The amount to shear the right points by verticallyfilter
- The colour filter to applypublic void draw(float x, float y, float width, float height, Color filter)
x
- The x location to draw the image aty
- The y location to draw the image atwidth
- The width to render the image atheight
- The height to render the image atfilter
- The color to filter with while drawingpublic void drawFlash(float x, float y, float width, float height)
x
- The x location to draw the image aty
- The y location to draw the image atwidth
- The width to render the image atheight
- The height to render the image atpublic void setCenterOfRotation(float x, float y)
x
- The x coordinate of center of rotation relative to the top left corner of the imagey
- The y coordinate of center of rotation relative to the top left corner of the imagepublic float getCenterOfRotationX()
public float getCenterOfRotationY()
public void drawFlash(float x, float y, float width, float height, Color col)
x
- The x location to draw the image aty
- The y location to draw the image atwidth
- The width to render the image atheight
- The height to render the image atcol
- The color for the sillohettepublic void drawFlash(float x, float y)
x
- The x location to draw the image aty
- The y location to draw the image atpublic void setRotation(float angle)
angle
- The angle to be setpublic float getRotation()
public float getAlpha()
public void setAlpha(float alpha)
alpha
- The alpha value to use when rendering this imagepublic void rotate(float angle)
angle
- The angle to add.public Image getSubImage(int x, int y, int width, int height)
x
- The x coordinate of the sub-imagey
- The y coordinate of the sub-imagewidth
- The width of the sub-imageheight
- The height of the sub-image
public void draw(float x, float y, float srcx, float srcy, float srcx2, float srcy2)
x
- The x position to draw the imagey
- The y position to draw the imagesrcx
- 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)public void draw(float x, float y, float x2, float y2, float srcx, float srcy, float srcx2, float srcy2)
x
- The x position to draw the imagey
- The y position to draw the imagex2
- The x position of the bottom right corner of the drawn imagey2
- The y position of the bottom right corner of the drawn imagesrcx
- 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)public void draw(float x, float y, float x2, float y2, float srcx, float srcy, float srcx2, float srcy2, Color filter)
x
- The x position to draw the imagey
- The y position to draw the imagex2
- The x position of the bottom right corner of the drawn imagey2
- The y position of the bottom right corner of the drawn imagesrcx
- 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 drawingpublic void drawEmbedded(float x, float y, float x2, float y2, float srcx, float srcy, float srcx2, float srcy2)
x
- The x position to draw the imagey
- The y position to draw the imagex2
- The x position of the bottom right corner of the drawn imagey2
- The y position of the bottom right corner of the drawn imagesrcx
- 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)public void drawEmbedded(float x, float y, float x2, float y2, float srcx, float srcy, float srcx2, float srcy2, Color filter)
x
- The x position to draw the imagey
- The y position to draw the imagex2
- The x position of the bottom right corner of the drawn imagey2
- The y position of the bottom right corner of the drawn imagesrcx
- 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 drawingpublic void drawWarped(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
x1
- The top left corner x coordinatey1
- The top left corner y coordinatex2
- The top right corner x coordinatey2
- The top right corner y coordinatex3
- The bottom right corner x coordinatey3
- The bottom right corner y coordinatex4
- The bottom left corner x coordinatey4
- The bottom left corner y coordinatepublic int getWidth()
public int getHeight()
public Image copy()
public Image getScaledCopy(float scale)
scale
- The scale to apply
public Image getScaledCopy(int width, int height)
width
- The width of the copyheight
- The height of the copy
public void ensureInverted()
public Image getFlippedCopy(boolean flipHorizontal, boolean flipVertical)
flipHorizontal
- True if we want to flip the image horizontallyflipVertical
- True if we want to flip the image vertically
public void endUse()
startUse()
public void startUse()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public Texture getTexture()
public void setTexture(Texture texture)
texture
- The texture used by this imagepublic Color getColor(int x, int y)
x
- The x coordinate of the pixely
- The y coordinate of the pixel
public boolean isDestroyed()
public void destroy() throws SlickException
SlickException
- Indicates a failure to release resources on the graphics cardpublic void flushPixelData()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |