artofillusion.image
Class ImageMap

java.lang.Object
  extended by artofillusion.image.ImageMap
Direct Known Subclasses:
HDRImage, MIPMappedImage, SVGImage

public abstract class ImageMap
extends java.lang.Object

ImageMap represents an image which can be used for texturing an object. The number of components can range from one (monochrome) to four (ARGB). It also provides a scaled down Image object which can be used to preview the image.

This is an abstract class. Subclasses implement specific ways of storing images.


Field Summary
static int PREVIEW_HEIGHT
           
static int PREVIEW_WIDTH
           
 
Constructor Summary
ImageMap()
           
 
Method Summary
abstract  float getAverageComponent(int component)
          Get the average value for a particular component, over the entire image.
abstract  void getColor(RGBColor theColor, boolean wrapx, boolean wrapy, double x, double y, double xsize, double ysize)
          Get the color at a particular location.
abstract  float getComponent(int component, boolean wrapx, boolean wrapy, double x, double y, double xsize, double ysize)
          Get the value of a single component at a particular location in the image.
abstract  int getComponentCount()
          Get the number of components in the image.
abstract  void getGradient(Vec2 grad, int component, boolean wrapx, boolean wrapy, double x, double y, double xsize, double ysize)
          Get the gradient of a single component at a particular location in the image.
abstract  int getHeight()
          Get the height of the image.
 int getID()
          Get an ID number which is unique (within this session) for this image.
abstract  java.awt.Image getPreview()
          Get a scaled down copy of the image, to use for previews.
abstract  int getWidth()
          Get the width of the image.
static ImageMap loadImage(java.io.File file)
          Construct an appropriate subclass of ImageMap from an image file.
abstract  void writeToStream(java.io.DataOutputStream out)
          Write out the object's representation to an output stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREVIEW_WIDTH

public static final int PREVIEW_WIDTH
See Also:
Constant Field Values

PREVIEW_HEIGHT

public static final int PREVIEW_HEIGHT
See Also:
Constant Field Values
Constructor Detail

ImageMap

public ImageMap()
Method Detail

loadImage

public static ImageMap loadImage(java.io.File file)
                          throws java.lang.Exception
Construct an appropriate subclass of ImageMap from an image file.

Throws:
java.lang.Exception

getWidth

public abstract int getWidth()
Get the width of the image.


getHeight

public abstract int getHeight()
Get the height of the image.


getComponentCount

public abstract int getComponentCount()
Get the number of components in the image.


getComponent

public abstract float getComponent(int component,
                                   boolean wrapx,
                                   boolean wrapy,
                                   double x,
                                   double y,
                                   double xsize,
                                   double ysize)
Get the value of a single component at a particular location in the image. The value is represented as a float between 0.0 and 1.0. The components are: 0: Red 1: Green 2: Blue 3: Alpha The location is specified by x and y, which must lie between 0 and 1. The value is averaged over a region of width (xsize, ysize). wrapx and wrapy specify whether, for purposes of interpolation, the image should be treated as wrapping around so that opposite edges touch each other.


getAverageComponent

public abstract float getAverageComponent(int component)
Get the average value for a particular component, over the entire image.


getColor

public abstract void getColor(RGBColor theColor,
                              boolean wrapx,
                              boolean wrapy,
                              double x,
                              double y,
                              double xsize,
                              double ysize)
Get the color at a particular location. The location is specified by x and y, which must lie between 0 and 1. The color is averaged over a region of width (xsize, ysize). wrapx and wrapy specify whether, for purposes of interpolation, the image should be treated as wrapping around so that opposite edges touch each other.


getGradient

public abstract void getGradient(Vec2 grad,
                                 int component,
                                 boolean wrapx,
                                 boolean wrapy,
                                 double x,
                                 double y,
                                 double xsize,
                                 double ysize)
Get the gradient of a single component at a particular location in the image. The location is specified by x and y, which must lie between 0 and 1. The value is averaged over a region of width (xsize, ysize) before the gradient is calculated. wrapx and wrapy specify whether, for purposes of interpolation, the image should be treated as wrapping around so that opposite edges touch each other.


getPreview

public abstract java.awt.Image getPreview()
Get a scaled down copy of the image, to use for previews. This Image will be no larger (but may be smaller) than PREVIEW_WIDTH by PREVIEW_HEIGHT.


getID

public int getID()
Get an ID number which is unique (within this session) for this image.


writeToStream

public abstract void writeToStream(java.io.DataOutputStream out)
                            throws java.io.IOException
Write out the object's representation to an output stream. Every ImageMap subclass must also define a constructor of the form public ImageMapSubclass(DataInputStream in) throws IOException, InvalidObjectException which reconstructs an image from its serialized representation.

Throws:
java.io.IOException


Copyright © 1999-2011 by Peter Eastman.