Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jgame
Interface JGImage

    public interface JGImage

Image functionality

Method Summary
`JGImage` | `crop(int x, int y, int width, int height)`
`JGImage` | `flip(boolean horiz, boolean vert)`
`JGPoint` | `getSize()` Get image size.
`boolean` | `isOpaque(int alpha_thresh)` True means the image may have some transparent pixels below the given alpha threshold, false means image is completely opaque.
`JGImage` | `loadImage(java.lang.String imgfile)` Load image from resource path (using getResource).
`void` | `purgeImage(java.lang.String imgfile)` Purge image with the given resourcename from the cache.
`JGImage` | `rotate(int angle)` for angle, only increments of 90 are allowed
`JGImage` | `rotateAny(double angle)` Image is rotated by rot (radians).
`JGImage` | `scale(int width, int height)` Returns a smoothly scaled image using getScaledInstance.
`JGImage` | `toDisplayCompatible(int thresh, JGColor bg_col, boolean fast, boolean bitmask)` Turn a (possibly) translucent or indexed image into a display-compatible bitmask image using the given alpha threshold and render-to-background colour, or to display-compatible translucent image.

Method Detail

### loadImage

    JGImage loadImage(java.lang.String imgfile)

  Load image from resource path (using getResource). Note that GIFs are loaded as _translucent_ indexed images. Images are cached: loading an image with the same name twice will get the cached image the second time. If you want to remove an image from the cache, use purgeImage. Throws JGError when there was an error.

### purgeImage

    void purgeImage(java.lang.String imgfile)

  Purge image with the given resourcename from the cache.

### getSize

    JGPoint getSize()

  Get image size. The object returned may be a reference to an internal variable, so do not change it!

### isOpaque

    boolean isOpaque(int alpha_thresh)

  True means the image may have some transparent pixels below the given alpha threshold, false means image is completely opaque. Implementations may choose to return false when they are not sure, but should return true whenever applicable to enable maximum performance benefits. Current implementations actually check the alpha channel pixel for pixel

### rotate

    JGImage rotate(int angle)

  for angle, only increments of 90 are allowed

### rotateAny

    JGImage rotateAny(double angle)

  Image is rotated by rot (radians). Resulting image is square with dimension max(width, height, 0.75*(width+height))

### flip

    JGImage flip(boolean horiz,
                 boolean vert)

### scale

    JGImage scale(int width,
                  int height)

  Returns a smoothly scaled image using getScaledInstance. This method has interesting behaviour. The scaled image retains its type (indexed/rgb and bitmask/translucent), and the algorithm tries to scale smoothly within these constraints. For indexed, interpolated pixels are rounded to the existing indexed colours. For bitmask, the behaviour depends on the platform. On WinXP/J1.2 I found that the colour _behind_ each transparent pixel is used to interpolate between nontransparent and transparent pixels. On BSD/J1.4 I found that the colours of transparent pixels are never used, and only the nontransparent pixels are used when interpolating a region with mixed transparent/nontransparent pixels.

### crop

    JGImage crop(int x,
                 int y,
                 int width,
                 int height)

### toDisplayCompatible

    JGImage toDisplayCompatible(int thresh,
                                JGColor bg_col,
                                boolean fast,
                                boolean bitmask)

  Turn a (possibly) translucent or indexed image into a display-compatible bitmask image using the given alpha threshold and render-to-background colour, or to display-compatible translucent image. In bitmask mode, the alpha values in the image are set to either 0 (below threshold) or 255 (above threshold). The render-to-background colour bg_col is used to determine how the pixels overlapping transparent pixels should be rendered. The fast algorithm just sets the colour behind the transparent pixels in the image (for bitmask source images); the slow algorithm actually renders the image to a background of bg_col (for translucent sources).

  Parameters:
    `thresh` - alpha threshold between 0 and 255
    `fast` - use fast algorithm (only set bg_col behind transp. pixels)
    `bitmask` - true=make bitmask, false=make translucent

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD