ImageTemplate

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.ctdp.rfdynhud.render
Class ImageTemplate

    java.lang.Object
      net.ctdp.rfdynhud.render.ImageTemplate

    public class ImageTemplate

extends java.lang.Object

The `ImageTemplate` is a container for image data configured through a property.

You can get a scaled representation of the image or directly draw a scaled version to another image.

Author:
  Marvin Froehlich (CTDP)

Constructor Summary
`ImageTemplate(java.lang.String name, java.awt.image.BufferedImage bufferedImage)`

Method Summary
`void` | `drawScaled(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, TextureImage2D texture, boolean clearBefore)` Draws a scaled representation of this image template to the given texture image.
`void` | `drawScaled(int x, int y, int width, int height, TextureImage2D texture, boolean clearBefore)` Draws a scaled representation of this image template to the given texture image.
`float` | `getBaseAspect()` Gets the base aspect ratio of the image.
`int` | `getBaseHeight()` Gets the base height of the image.
`int` | `getBaseWidth()` Gets the base width of the image.
`java.lang.String` | `getName()` Gets the image template's name.
`TextureImage2D` | `getScaledTextureImage(int width, int height, boolean usePowerOfTwoSize)` Gets a scaled representation of this image template.
`TextureImage2D` | `getScaledTextureImage(int width, int height, TextureImage2D possibleResult, boolean tryToResize)` Gets a scaled representation of this image template.
`TransformableTexture` | `getScaledTransformableTexture(int width, int height, boolean usePowerOfTwoSize)` Gets a `TransformableTexture` with this image drawn onto it.
`TransformableTexture` | `getScaledTransformableTexture(int width, int height, TransformableTexture possibleResult, boolean tryToResize)` Gets a `TransformableTexture` with this image drawn onto it.
`TransformableTexture` | `getScaledTransformableTexture(int width, int height, TransformableTexture possibleResult, boolean tryToResize, boolean[] changeInfo)` Gets a `TransformableTexture` with this image drawn onto it.
`TextureImage2D` | `getTextureImage()` Gets a representation of this image template.
`TransformableTexture` | `getTransformableTexture()` Gets a `TransformableTexture` with this image drawn onto it using base size.
`boolean` | `hasAlpha()` Gets, whether the image has an alpha channel or not.

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

Constructor Detail

### ImageTemplate

    public ImageTemplate(java.lang.String name,
                         java.awt.image.BufferedImage bufferedImage)

Method Detail

### getName

    public final java.lang.String getName()

  Gets the image template's name.

  Returns:
    the image template's name.

### getBaseWidth

    public final int getBaseWidth()

  Gets the base width of the image. This can be the physical image size or the size defined in an SVG image.

  Returns:
    the base width of the image.

### getBaseHeight

    public final int getBaseHeight()

  Gets the base height of the image. This can be the physical image size or the size defined in an SVG image.

  Returns:
    the base height of the image.

### getBaseAspect

    public final float getBaseAspect()

  Gets the base aspect ratio of the image.

  Returns:
    the base aspect ratio of the image.

### hasAlpha

    public final boolean hasAlpha()

  Gets, whether the image has an alpha channel or not.

  Returns:
    whether the image has an alpha channel or not.

### drawScaled

    public void drawScaled(int sx,
                           int sy,
                           int sw,
                           int sh,
                           int dx,
                           int dy,
                           int dw,
                           int dh,
                           TextureImage2D texture,
                           boolean clearBefore)

  Draws a scaled representation of this image template to the given texture image.

  Parameters:
    `sx` - source x
    `sy` - source y
    `sw` - source width
    `sh` - source height
    `dx` - destination x
    `dy` - destination y
    `dw` - destination width
    `dh` - destination height
    `texture` - the texture to draw on
    `clearBefore` - clear before drawing?

### drawScaled

    public void drawScaled(int x,
                           int y,
                           int width,
                           int height,
                           TextureImage2D texture,
                           boolean clearBefore)

  Draws a scaled representation of this image template to the given texture image.

  Parameters:
    `x` - destination x
    `y` - destination y
    `width` - destination width
    `height` - destination height
    `texture` - the texture to draw on
    `clearBefore` - clear before drawing?

### getScaledTextureImage

    public TextureImage2D getScaledTextureImage(int width,
                                                int height,
                                                boolean usePowerOfTwoSize)

  Gets a scaled representation of this image template.

  Parameters:
    `width` - destination width
    `height` - destination height
    `usePowerOfTwoSize` - if true, the created texture is created with power of two width and height (with used size set to the desired values). This is useful in editor mode avoid constant recreations.
  Returns:
    a scaled representation of this image template.

### getScaledTextureImage

    public final TextureImage2D getScaledTextureImage(int width,
                                                      int height,
                                                      TextureImage2D possibleResult,
                                                      boolean tryToResize)

  Gets a scaled representation of this image template. If the possibleResult is non null and has the correct size, it is returned.

  Parameters:
    `width` - destination width
    `height` - destination height
    `possibleResult` - this instance is possibly returned, if parameters match
    `tryToResize` - if true, the passed in texture is resized to the given size, if the max size is sufficient. This is useful in editor mode avoid constant recreations.
  Returns:
    a scaled representation of this image template.

### getTextureImage

    public final TextureImage2D getTextureImage()

  Gets a representation of this image template. If this template encapsulates a fixed sized image, pixel data is copied directly, otherwise it is drawed at the base size.

  Returns:
    a representation of this image template with base size.

### getScaledTransformableTexture

    public TransformableTexture getScaledTransformableTexture(int width,
                                                              int height,
                                                              boolean usePowerOfTwoSize)

  Gets a `TransformableTexture` with this image drawn onto it.

  Parameters:
    `width` - destination width
    `height` - destination height
    `usePowerOfTwoSize` - if true, the created texture is created with power of two width and height (with used size set to the desired values). This is useful in editor mode to avoid constant recreations.
  Returns:
    a `TransformableTexture` with this image drawn onto it.

### getScaledTransformableTexture

    public TransformableTexture getScaledTransformableTexture(int width,
                                                              int height,
                                                              TransformableTexture possibleResult,
                                                              boolean tryToResize,
                                                              boolean[] changeInfo)

  Gets a `TransformableTexture` with this image drawn onto it. If the possibleResult is non null and has the correct size, it is returned.

  Parameters:
    `width` - destination width
    `height` - destination height
    `possibleResult` - this instance is possibly returned, if parameters match
    `tryToResize` - if true, the passed in texture is resized to the given size, if the max size is sufficient. This is useful in editor mode avoid constant recreations.
    `changeInfo` - if non `null` the first element tells you, whether 'possibleResult' has been recycled and the second element, whether the texture has been (re)drawn
  Returns:
    a `TransformableTexture` with this image drawn onto it.

### getScaledTransformableTexture

    public TransformableTexture getScaledTransformableTexture(int width,
                                                              int height,
                                                              TransformableTexture possibleResult,
                                                              boolean tryToResize)

  Gets a `TransformableTexture` with this image drawn onto it. If the possibleResult is non null and has the correct size, it is returned.

  Parameters:
    `width` - destination width
    `height` - destination height
    `possibleResult` - this instance is possibly returned, if parameters match
    `tryToResize` - if true, the passed in texture is resized to the given size, if the max size is sufficient. This is useful in editor mode avoid constant recreations.
  Returns:
    a `TransformableTexture` with this image drawn onto it.

### getTransformableTexture

    public TransformableTexture getTransformableTexture()

  Gets a `TransformableTexture` with this image drawn onto it using base size.

  Returns:
    a `TransformableTexture` with this image drawn onto it.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD