sub_arctic.output
Class loaded_image

java.lang.Object
  |
  +--sub_arctic.output.loaded_image
Direct Known Subclasses:
styled_image

public class loaded_image
extends java.lang.Object
implements java.io.Serializable

A class to encapsulate a potentially asynchronously loaded image. This class does blocking for operations that need to wait until the image is fully loaded (such as requests for the image's size).

See Also:
Serialized Form

Field Summary
protected  java.awt.Image _image
          The image we encapsulate.
protected  boolean _is_loaded
          Do we know that the image has been loaded
 
Constructor Summary
loaded_image(java.awt.Image img)
          Construct from an Image (this image is marked as not loaded yet).
loaded_image(int[] data, int w, int h)
          Construct from in memory data.
loaded_image(int w, int h)
          Construct a blank in memory image of the given size and force it to be "loaded" (not clear what that means for in-memory images, but it seems to be required).
loaded_image(loaded_image other, int x, int y, int w, int h)
          Construct an in memory image from part of another image.
 
Method Summary
 drawable get_drawable()
          Get a drawable that can be used to draw on this image (similar to getGraphics() on an AWT Image object).
 int height()
          Get the image height, waiting for the image to load if necessary
static loaded_image image_from_intensity_map(loaded_image map, java.awt.Color color, int ti)
          This function creates a nice looking loaded_image from an an intensity image and a color.
 java.awt.Image image()
          Get the image, but block if it is not completely loaded.
 boolean is_loaded()
          Indicate whether the image is known to be loaded already.
 java.awt.Image raw_image()
          Get access to the encapsulated image without blocking if it is not loaded yet.
 void set_is_loaded(boolean val)
          Public write access to _is_loaded.
 int width()
          Get the image width, waiting for the image to load if necessary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_is_loaded

protected transient boolean _is_loaded
Do we know that the image has been loaded

_image

protected transient java.awt.Image _image
The image we encapsulate.
Constructor Detail

loaded_image

public loaded_image(java.awt.Image img)
Construct from an Image (this image is marked as not loaded yet).
Parameters:
Image - img the Image to create the loaded_image from

loaded_image

public loaded_image(int w,
                    int h)
Construct a blank in memory image of the given size and force it to be "loaded" (not clear what that means for in-memory images, but it seems to be required). The image is filled with the systems default background color.
Parameters:
int - w the width of the image in pixels.
int - h the height of the image in pixels.

loaded_image

public loaded_image(int[] data,
                    int w,
                    int h)
Construct from in memory data. This image is marked as unloaded.
Parameters:
int[] - the data to build the image from
int - w the width of the image
int - h the height of the image

loaded_image

public loaded_image(loaded_image other,
                    int x,
                    int y,
                    int w,
                    int h)
Construct an in memory image from part of another image.
Parameters:
loaded_image - other the image we take our subimage from
int - x the left corner of the subimage
int - y the top corner of the subimage
int - w the width of the subimage in pixels.
int - h the height of the subimage in pixels.
Method Detail

is_loaded

public boolean is_loaded()
Indicate whether the image is known to be loaded already.
Returns:
boolean indicating load status (true == loaded)

set_is_loaded

public void set_is_loaded(boolean val)
Public write access to _is_loaded. WARNING: This is here only because its required for a bug workaround. Once, the bug is fixed, this will probably go away.

raw_image

public java.awt.Image raw_image()
Get access to the encapsulated image without blocking if it is not loaded yet.
Returns:
Image the raw image (might not be loaded)

image

public java.awt.Image image()
Get the image, but block if it is not completely loaded.
Returns:
Image the encapsulated Image

width

public int width()
Get the image width, waiting for the image to load if necessary
Returns:
int the width of the loaded_image in pixels

height

public int height()
Get the image height, waiting for the image to load if necessary
Returns:
int the height of the loaded_image in pixels

get_drawable

public drawable get_drawable()
Get a drawable that can be used to draw on this image (similar to getGraphics() on an AWT Image object).
Returns:
drawable a context for drawing on this image

image_from_intensity_map

public static loaded_image image_from_intensity_map(loaded_image map,
                                                    java.awt.Color color,
                                                    int ti)
This function creates a nice looking loaded_image from an an intensity image and a color. The intensity image is a black and white image where the ti parameter (RGB (ti,ti,ti) means transparent.

All shades of grey (other than the transparency intensity) are mapped to an intensity in of the color passed, proportional to their value (between 0 and 255).

Although these will get you "feathered" images, there is not a lot of dynamic range before your chosen color falls off to black. I would recommend making your intensity map have the values 180+ to get reasonable results.

Parameters:
loaded_image - map the intensity map.
Color - color the target color.
int - ti this the intensity which should be transparent.
Returns:
loaded_image the result image.