org.newdawn.slick
Class BigImage

java.lang.Object
  extended by org.newdawn.slick.Image
      extended by org.newdawn.slick.BigImage
All Implemented Interfaces:
Renderable

public class BigImage
extends Image

An image implementation that handles loaded images that are larger than the maximum texture size supported by the card. In most cases it makes sense to make sure all of your image resources are less than 512x512 in size when using OpenGL. However, in the rare circumstances where this isn't possible this implementation can be used to draw a tiled version of the image built from several smaller textures. This implementation does come with limitations and some performance impact however - so use only when absolutely required. TODO: The code in here isn't pretty, really needs revisiting with a comment stick.

Author:
kevin

Field Summary
protected static SGL GL
          The renderer to use for all GL operations
 
Fields inherited from class org.newdawn.slick.Image
alpha, angle, BOTTOM_LEFT, BOTTOM_RIGHT, centerX, centerY, corners, destroyed, FILTER_LINEAR, FILTER_NEAREST, height, inited, inUse, name, pixelData, ref, texture, textureHeight, textureOffsetX, textureOffsetY, textureWidth, TOP_LEFT, TOP_RIGHT, width
 
Constructor Summary
BigImage(LoadableImageData data, java.nio.ByteBuffer imageBuffer, int filter)
          Create a new big image by loading it from the specified image data
BigImage(LoadableImageData data, java.nio.ByteBuffer imageBuffer, int filter, int tileSize)
          Create a new big image by loading it from the specified image data
BigImage(java.lang.String ref)
          Create a new big image by loading it from the specified reference
BigImage(java.lang.String ref, int filter)
          Create a new big image by loading it from the specified reference
BigImage(java.lang.String ref, int filter, int tileSize)
          Create a new big image by loading it from the specified reference
 
Method Summary
 void bind()
          Not supported in BigImage
 Image copy()
          Not supported in BigImage
 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 endUse()
          Not supported in BigImage
 void ensureInverted()
          Not supported in BigImage
 Color getColor(int x, int y)
          Not supported in BigImage
 Image getFlippedCopy(boolean flipHorizontal, boolean flipVertical)
          Get a copy image flipped on potentially two axis
 Graphics getGraphics()
          Not supported in BigImage
 int getHorizontalImageCount()
          Get a count of the number images that build this image up horizontally
static int getMaxSingleImageSize()
          Get the maximum size of an image supported by the underlying hardware.
 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 offsetX, int offsetY)
          Get a sub-image that builds up this image.
 Image getSubImage(int x, int y, int width, int height)
          Get a sub-part of this image.
 Texture getTexture()
          Not supported in BigImage
 Image getTile(int x, int y)
          Get a sub tile of this big image.
 int getVerticalImageCount()
          Get a count of the number images that build this image up vertically
protected  void initImpl()
          Hook for subclasses to perform initialisation
protected  void reinit()
          Reinitialise internal data
 void setTexture(Texture texture)
          Not supported in BigImage
 void startUse()
          Not supported in BigImage
 java.lang.String toString()
           
 
Methods inherited from class org.newdawn.slick.Image
clampTexture, drawSheared, drawWarped, flushPixelData, getAlpha, getCenterOfRotationX, getCenterOfRotationY, getFilter, getHeight, getName, getResourceReference, getRotation, getTextureHeight, getTextureOffsetX, getTextureOffsetY, getTextureWidth, getWidth, init, isDestroyed, rotate, setAlpha, setCenterOfRotation, setColor, setColor, setFilter, setImageColor, setImageColor, setName, setRotation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

GL

protected static SGL GL
The renderer to use for all GL operations

Constructor Detail

BigImage

public BigImage(java.lang.String ref)
         throws SlickException
Create a new big image by loading it from the specified reference

Parameters:
ref - The reference to the image to load
Throws:
SlickException - Indicates we were unable to locate the resource

BigImage

public BigImage(java.lang.String ref,
                int filter)
         throws SlickException
Create a new big image by loading it from the specified reference

Parameters:
ref - The reference to the image to load
filter - The image filter to apply (@see #Image.FILTER_NEAREST)
Throws:
SlickException - Indicates we were unable to locate the resource

BigImage

public BigImage(java.lang.String ref,
                int filter,
                int tileSize)
         throws SlickException
Create a new big image by loading it from the specified reference

Parameters:
ref - The reference to the image to load
filter - The image filter to apply (@see #Image.FILTER_NEAREST)
tileSize - The maximum size of the tiles to use to build the bigger image
Throws:
SlickException - Indicates we were unable to locate the resource

BigImage

public BigImage(LoadableImageData data,
                java.nio.ByteBuffer imageBuffer,
                int filter)
Create a new big image by loading it from the specified image data

Parameters:
data - The pixelData to use to create the image
imageBuffer - The buffer containing texture data
filter - The image filter to apply (@see #Image.FILTER_NEAREST)

BigImage

public BigImage(LoadableImageData data,
                java.nio.ByteBuffer imageBuffer,
                int filter,
                int tileSize)
Create a new big image by loading it from the specified image data

Parameters:
data - The pixelData to use to create the image
imageBuffer - The buffer containing texture data
filter - The image filter to apply (@see #Image.FILTER_NEAREST)
tileSize - The maximum size of the tiles to use to build the bigger image
Method Detail

getMaxSingleImageSize

public static final int getMaxSingleImageSize()
Get the maximum size of an image supported by the underlying hardware.

Returns:
The maximum size of the textures supported by the underlying hardware.

getTile

public Image getTile(int x,
                     int y)
Get a sub tile of this big image. Useful for debugging

Parameters:
x - The x tile index
y - The y tile index
Returns:
The image used for this tile

bind

public void bind()
Not supported in BigImage

Overrides:
bind in class Image
See Also:
Image.bind()

copy

public Image copy()
Not supported in BigImage

Overrides:
copy in class Image
Returns:
The copy of this image
See Also:
Image.copy()

draw

public void draw()
Description copied from class: Image
Draw this image at the current location

Overrides:
draw in class Image
See Also:
Image.draw()

draw

public void draw(float x,
                 float y,
                 Color filter)
Description copied from class: Image
Draw this image at the specified location

Overrides:
draw in class Image
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
See Also:
Image.draw(float, float, org.newdawn.slick.Color)

draw

public void draw(float x,
                 float y,
                 float scale,
                 Color filter)
Description copied from class: Image
Draw the image with a given scale

Overrides:
draw in class Image
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
See Also:
Image.draw(float, float, float, org.newdawn.slick.Color)

draw

public void draw(float x,
                 float y,
                 float width,
                 float height,
                 Color filter)
Description copied from class: Image
Draw this image at a specified location and size

Overrides:
draw in class Image
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
See Also:
Image.draw(float, float, float, float, org.newdawn.slick.Color)

draw

public void draw(float x,
                 float y,
                 float x2,
                 float y2,
                 float srcx,
                 float srcy,
                 float srcx2,
                 float srcy2)
Description copied from class: Image
Draw a section of this image at a particular location and scale on the screen

Overrides:
draw in class Image
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)
See Also:
Image.draw(float, float, float, float, float, float, float, float)

draw

public void draw(float x,
                 float y,
                 float srcx,
                 float srcy,
                 float srcx2,
                 float srcy2)
Description copied from class: Image
Draw a section of this image at a particular location and scale on the screen

Overrides:
draw in class Image
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)
See Also:
Image.draw(float, float, float, float, float, float)

draw

public void draw(float x,
                 float y,
                 float width,
                 float height)
Description copied from class: Image
Draw this image at a specified location and size

Overrides:
draw in class Image
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
See Also:
Image.draw(float, float, float, float)

draw

public void draw(float x,
                 float y,
                 float scale)
Description copied from class: Image
Draw the image with a given scale

Overrides:
draw in class Image
Parameters:
x - The x position to draw the image at
y - The y position to draw the image at
scale - The scaling to apply
See Also:
Image.draw(float, float, float)

draw

public void draw(float x,
                 float y)
Description copied from class: Image
Draw this image at the specified location

Specified by:
draw in interface Renderable
Overrides:
draw in class Image
Parameters:
x - The x location to draw the image at
y - The y location to draw the image at
See Also:
Image.draw(float, float)

drawEmbedded

public void drawEmbedded(float x,
                         float y,
                         float width,
                         float height)
Description copied from class: Image
Draw this image as part of a collection of images

Overrides:
drawEmbedded in class Image
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
See Also:
Image.drawEmbedded(float, float, float, float)

drawFlash

public void drawFlash(float x,
                      float y,
                      float width,
                      float height)
Description copied from class: Image
Draw this image at a specified location and size as a silohette

Overrides:
drawFlash in class Image
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
See Also:
Image.drawFlash(float, float, float, float)

drawFlash

public void drawFlash(float x,
                      float y)
Description copied from class: Image
Draw this image at a specified location and size in a white silohette

Overrides:
drawFlash in class Image
Parameters:
x - The x location to draw the image at
y - The y location to draw the image at
See Also:
Image.drawFlash(float, float)

endUse

public void endUse()
Not supported in BigImage

Overrides:
endUse in class Image
See Also:
Image.endUse()

startUse

public void startUse()
Not supported in BigImage

Overrides:
startUse in class Image
See Also:
Image.startUse()

ensureInverted

public void ensureInverted()
Not supported in BigImage

Overrides:
ensureInverted in class Image
See Also:
Image.ensureInverted()

getColor

public Color getColor(int x,
                      int y)
Not supported in BigImage

Overrides:
getColor in class 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
See Also:
Image.getColor(int, int)

getFlippedCopy

public Image getFlippedCopy(boolean flipHorizontal,
                            boolean flipVertical)
Description copied from class: Image
Get a copy image flipped on potentially two axis

Overrides:
getFlippedCopy in class Image
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
See Also:
Image.getFlippedCopy(boolean, boolean)

getGraphics

public Graphics getGraphics()
                     throws SlickException
Not supported in BigImage

Overrides:
getGraphics in class Image
Returns:
The graphics context used to render to this image
Throws:
SlickException - Indicates a failure to create a graphics context
See Also:
Image.getGraphics()

getScaledCopy

public Image getScaledCopy(float scale)
Description copied from class: Image
Get a scaled copy of this image with a uniform scale

Overrides:
getScaledCopy in class Image
Parameters:
scale - The scale to apply
Returns:
The new scaled image
See Also:
Image.getScaledCopy(float)

getScaledCopy

public Image getScaledCopy(int width,
                           int height)
Description copied from class: Image
Get a scaled copy of this image

Overrides:
getScaledCopy in class Image
Parameters:
width - The width of the copy
height - The height of the copy
Returns:
The new scaled image
See Also:
Image.getScaledCopy(int, int)

getSubImage

public Image getSubImage(int x,
                         int y,
                         int width,
                         int height)
Description copied from class: Image
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.

Overrides:
getSubImage in class Image
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
See Also:
Image.getSubImage(int, int, int, int)

getTexture

public Texture getTexture()
Not supported in BigImage

Overrides:
getTexture in class Image
Returns:
The OpenGL texture holding this image
See Also:
Image.getTexture()

initImpl

protected void initImpl()
Description copied from class: Image
Hook for subclasses to perform initialisation

Overrides:
initImpl in class Image
See Also:
Image.initImpl()

reinit

protected void reinit()
Description copied from class: Image
Reinitialise internal data

Overrides:
reinit in class Image
See Also:
Image.reinit()

setTexture

public void setTexture(Texture texture)
Not supported in BigImage

Overrides:
setTexture in class Image
Parameters:
texture - The texture used by this image
See Also:
Image.setTexture(org.newdawn.slick.opengl.Texture)

getSubImage

public Image getSubImage(int offsetX,
                         int offsetY)
Get a sub-image that builds up this image. Note that the offsets used will depend on the maximum texture size on the OpenGL hardware

Parameters:
offsetX - The x position of the image to return
offsetY - The y position of the image to return
Returns:
The image at the specified offset into the big image

getHorizontalImageCount

public int getHorizontalImageCount()
Get a count of the number images that build this image up horizontally

Returns:
The number of sub-images across the big image

getVerticalImageCount

public int getVerticalImageCount()
Get a count of the number images that build this image up vertically

Returns:
The number of sub-images down the big image

toString

public java.lang.String toString()
Overrides:
toString in class Image
See Also:
Image.toString()

destroy

public void destroy()
             throws SlickException
Destroy the image and release any native resources. Calls on a destroyed image have undefined results

Overrides:
destroy in class Image
Throws:
SlickException - Indicates a failure to release resources on the graphics card

draw

public void draw(float x,
                 float y,
                 float x2,
                 float y2,
                 float srcx,
                 float srcy,
                 float srcx2,
                 float srcy2,
                 Color filter)
Description copied from class: Image
Draw a section of this image at a particular location and scale on the screen

Overrides:
draw in class Image
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
See Also:
Image.draw(float, float, float, float, float, float, float, float, org.newdawn.slick.Color)

drawCentered

public void drawCentered(float x,
                         float y)
Description copied from class: Image
Draw the image based on it's center

Overrides:
drawCentered in class Image
Parameters:
x - The x coordinate to place the image's center at
y - The y coordinate to place the image's center at
See Also:
Image.drawCentered(float, float)

drawEmbedded

public void drawEmbedded(float x,
                         float y,
                         float x2,
                         float y2,
                         float srcx,
                         float srcy,
                         float srcx2,
                         float srcy2,
                         Color filter)
Description copied from class: Image
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.

Overrides:
drawEmbedded in class Image
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
See Also:
Image.drawEmbedded(float, float, float, float, float, float, float, float, org.newdawn.slick.Color)

drawEmbedded

public void drawEmbedded(float x,
                         float y,
                         float x2,
                         float y2,
                         float srcx,
                         float srcy,
                         float srcx2,
                         float srcy2)
Description copied from class: Image
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.

Overrides:
drawEmbedded in class Image
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)
See Also:
Image.drawEmbedded(float, float, float, float, float, float, float, float)

drawFlash

public void drawFlash(float x,
                      float y,
                      float width,
                      float height,
                      Color col)
Description copied from class: Image
Draw this image at a specified location and size as a silohette

Overrides:
drawFlash in class Image
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
See Also:
Image.drawFlash(float, float, float, float, org.newdawn.slick.Color)

drawSheared

public void drawSheared(float x,
                        float y,
                        float hshear,
                        float vshear)
Description copied from class: Image
Draw this image at a specified location and size

Overrides:
drawSheared in class Image
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
See Also:
Image.drawSheared(float, float, float, float)


Copyright © 2006 New Dawn Software. All Rights Reserved.