DirectX Media for Animation Java Reference Previous
Previous
Classes
Classes
Index
Index
Next
Next

ImageBvr Class

Methods , Fields

public class ImageBvr extends Behavior {
    // Fields
    public static ImageBvr detectableEmptyImage;
    public static ImageBvr emptyImage;
    
    // Methods
    public Bbox2Bvr boundingBox();
    public ImageBvr clip(MatteBvr matte);
    public ImageBvr clipPolygon(Point2Bvr[] points);
    public ImageBvr crop(Point2Bvr minPt, Point2Bvr maxPt);
    public ImageBvr mapToUnitSquare();
    public ImageBvr opacity(NumberBvr opac);
    public ImageBvr tile();
    public ImageBvr transform(Transform2Bvr xf);
    public ImageBvr undetectable();

    public static ImageBvr gradientPolygon(Point2Bvr[] pts, ColorBvr[] colors);
    public static ImageBvr gradientQuadrant(ColorBvr innerColor, ColorBvr outerColor, NumberBvr numPts);
    public static ImageBvr gradientSquare(ColorBvr lowerLeft, ColorBvr upperLeft, ColorBvr upperRight, ColorBvr lowerRight);
    public static ImageBvr importImage(String pathname) throws IllegalImport;
    public static ImageBvr newUninitBvr();
    public static ImageBvr overlay(ImageBvr i1, ImageBvr i2);
    public static ImageBvr polyline(Point2Bvr[] points, ColorBvr col);
    public static ImageBvr solidColorImage(ColorBvr col);
    public static ImageBvr strokeImage(Path2Bvr path, LinestyleBvr style, ColorBvr color);
        
}

Creates an object that represents an image behavior. Much like a bitmap, an image is a two-dimensional picture composed of individual picture elements. Like other behaviors, however, the value of the picture elements can change over time.

Every image behavior consists of an infinite set of two-dimensional points, each representing a picture element and each having color, opacity, and detectability attributes. Colors in an image are defined using color behaviors. Opacity values are number behaviors, and can range in value from 0 through 1, with 0 for fully transparent and 1 for fully opaque. Only points that are "non-transparent" have any visible effect when the image is output or combined with other images.

Points in the image are either detectable or not. If a point is detectable, the image fires a pick event whenever the mouse passes over it.

The bounding box operation is used to construct and compose media, and different types of images and behaviors provide specific bounding boxes. This means, for example, that the bounding box of an image is not defined as the smallest axis-aligned, enclosing region of the non-transparent parts of an image. Instead, bounding boxes are defined on a per-operation basis. This means, for example, that the clipPolygon method has its own definition of a bounding box, defined below.

For more information about behaviors, see the Behavior class.


Methods


boundingBox

public Bbox2Bvr boundingBox();

Creates a box behavior that defines the box that encloses all non-transparent portions of the image behavior.

Return Value:

Returns the Bbox2Bvr object.


clip

public ImageBvr clip(MatteBvr matte);

Creates a new image behavior by clipping the original image. The new image consists of the portion of the original image that is within the region(s) defined by the given matte behavior. The bounding box of an image clipped to a matte is the intersection of the matte's bounding box (the axis-aligned box that surrounds the matte), and the bounding box of the underlying image.

Return Value:

Returns the ImageBvr object.

ParameterDescription
matte The MatteBvr object.


clipPolygon

public ImageBvr clipPolygon(Point2Bvr[] points);

Creates a new image behavior by clipping the original image. The new image consists of the portion of the original image that is within the closed figure defined by the given point behaviors. The bounding box is the intersection of the box surrounding the points of the polygon with the box of the underlying image.

Return Value:

Returns the ImageBvr object.

ParameterDescription
points The Point2Bvr object representing the endpoints of the line segments that define the figure. If the first and last points are not the same, these points are implicitly connected to close the figure.


crop

public ImageBvr crop(Point2Bvr minPt, Point2Bvr maxPt);

Creates a new image behavior by cropping the original image. The new image consists of the portion of the original image that is within the region given by minPt and maxPt. The bounding box of a cropped image is the intersection of the crop box and the box of the underlying image.

Return Value:

Returns the ImageBvr object.

ParameterDescription
minPt and maxPt The Point2Bvr objects representing the lower-left and upper-right corners of the box enclosing the portion of the original image to use.


mapToUnitSquare

public ImageBvr mapToUnitSquare();

Creates an image that is mapped to the unit square. This is a square at coordinates [(0,0) (1,1)]. It is commonly used for images that will be textured because a geometry's texture coordinates generally span the unit square. It is also used for transforming an image into a space where it is easy to manipulate.


opacity

public ImageBvr opacity(NumberBvr opac);

Creates an image behavior in which the opacity value for each point is set to the given number behavior. By default, an image's opacity is 1. The bounding box is simply the bounding box of the underlying image itself.

Return Value:

Returns the ImageBvr object.

ParameterDescription
opac The NumberBvr object representing the opacity value. The image is fully opaque if the value is 1, and fully transparent if the value is 0.

Remarks:

Opacity values can range from 0.0 to 1.0. If the corresponding number behavior has a value outside this range, the integer part of the value is discarded and only the fractional part is used. This attribute composes values. The resulting opacity is the new value times the old value.


tile

public ImageBvr tile();

Creates a new image behavior that consists of the original image tiled (repeated) in all directions. The bounding box is the infinite bounding box.

Return Value:

Returns the ImageBvr object.


transform

public ImageBvr transform(Transform2Bvr xf);

Creates a new image behavior that is the result of applying the given transformation to the points in the original image behavior. For example, you can double the size of the opaque portion of the image that is the result of applying a transformation that scales by 2. The bounding box of a transformed image is determined by applying the transform to the bounding box of the underlying image and then enclosing the resultant quadrilateral with an axis-aligned box.

Return Value:

Returns the ImageBvr object.

ParameterDescription
xf The Transform2Bvr object.

Remarks:

This attribute composes values.


undetectable

public ImageBvr undetectable();

Creates a new undetectable image behavior from the original image.

Return Value:

Returns the ImageBvr object.


gradientPolygon

public static ImageBvr gradientPolygon(Point2Bvr[] pts, ColorBvr[] colors);

Creates a polygon from an array of points and an array of colors. The polygon has a smooth interpolation between the colors at the vertices. This interpolation is in RGB space. The image is transparent and unpickable outside the polygon. The polygon must be convex and fanned, with at least 3 vertices. The tessellation into triangles occurs by fanning around the first vertex. If, for example, the first triangle is from vertices [0, 1, 2], the second is from [0, 2, 3], and so on. The tessellation determines how the color interpolation is done. The bounding box is the box surrounding the points of the polygon.

Return Value:

Returns the ImageBvr object.

ParameterDescription
pts The array of points that determine the polygon's vertices.
colors The array of colors corresponding to the vertices.


gradientQuadrant

public static ImageBvr gradientQuadrant(ColorBvr innerColor, ColorBvr outerColor, NumberBvr numPts);

Creates an image behavior with a radial fill. The image has a tessellation of a quarter-circle with the origin at [0,0] and a radius of 1. This is the upper-right hand quadrant. The image is transparent and unpickable outside of this quadrant. The innerColor is used at the origin and the outerColor at all the exterior points. The interpolation is between these two colors and occurs in RGB space. The quarter-circle has numPts points along its outer edge. This means the number of points along the quadrant is (numPts + 1), and the number of intermediate points is (numPts - 1). For example, if numPts is 3, there will be 3 edges, with 4 points at 0, 30, 60, and 90 degrees. The image is, therefore, a tessellation of a quarter-circle rather than a true quarter circle. To achieve a true quarter-circle, clip the image to a quarter-circle matte. To achieve a semi-circle or a full-circle, rotate and overlay a single instance of the quadrant. The bounding box is the box (0, 0) to (1, 1).

Return Value:

Returns the ImageBvr object.

ParameterDescription
innerColor The color at the origin of the quarter-circle.
outerColor The color at the exterior points of the quarter-circle.
numPts The number of points along the outer edge of the quarter-circle.


gradientSquare

public static ImageBvr gradientSquare(ColorBvr lowerLeft, ColorBvr upperLeft, ColorBvr upperRight, ColorBvr lowerRight);

Creates an image behavior with a square color wash. The image is a unit-sized square, centered at the origin, reaching from [-0.5, -0.5] to [0.5, 0.5]. The image contains the specified colors in the specified corners. The gradient fills are determined by bilinearly interpolating between these specified colors. (This means that, rather than being simply a four-cornered polygon, it is a polygon with four corners plus a point in the middle that is the average of the four colors.) The image is transparent and unpickable outside of this region. The interpolation is in RGB space. The bounding box is a box from (-0.5, -0.5) to (0.5, 0.5).

Return Value:

Returns the ImageBvr object.

ParameterDescription
lowerLeft The color in the lower-left hand corner of square.
upperLeft The color in the upper-left hand corner of the square.
upperRight The color in the upper-right hand corner of the square.
lowerRight The color in the lower-right hand corner of the square.


importImage

public static importImage(String pathname);

Creates an image behavior by importing the given bitmap. The pixels of the bitmap are mapped to points in the image such that the center of the bitmap is placed at (0,0). The extent of the points affected depends on the width and height of the bitmap in pixels and the resolution of the bitmap in pixels per meter. The bounding box of an imported image is calculated as follows: If the pixel dimensions are WxH, and given that:

halfWidthMeters = Miscellany.pixel * W/2;
halfHeightMeters = Miscellany.pixel * H/2;

then the bounding box will be (-halfWidthMeters, -halfHeightMeters) to (halfWidthMeters, halfHeightMeters) with the resultant image centered at the origin.

Return Value:

Returns the ImageBvr object.

ParameterDescription
pathname A character string specifying the URL or the name of the file.

Remarks:

The file formats that can be imported are .JPG, .BMP, and .GIF.

Throws:

IllegalImport The given file does not exist or is not in a valid format.


newUninitBvr

public static ImageBvr newUninitBvr();

This method allows you to refer to an ImageBvr behavior before that behavior has been defined. With this method you can create the behavior and use it in the definition of other behaviors, but not actually define its contents until some later point. (This is accomplished with the init method, which is available on all behaviors.) The system generates a run-time error if you initialize a non-uninitialized behavior, initialize an uninitialized behavior that has already been initialized, or run an initialized behavior that has not yet been initialized.

Return Value:

Returns the ImageBvr object.


overlay

public static ImageBvr overlay(ImageBvr i1, ImageBvr i2);

Creates an image behavior by laying the image behavior i1 over the image behavior i2. The new image consists of all fully opaque points of i1, all points of i2 that are under fully transparent points in i1, and all partially opaque points of i1 modified such that the new point is a combination of the i1 point and the i2 point under it. The bounding box of a set of overlaid images is simply the union of the bounding boxes of the images themselves.

Return Value:

Returns the ImageBvr object.

ParameterDescription
i1 and i2 The ImageBvr objects.


polyline

public static ImageBvr polyline(int numPts, Point2Bvr[] points, ColorBvr col);

Creates an image behavior and applies the given color behavior to the points in the image that are within the line segments drawn between the given points. The default line-style has flat ends, a beveled join, a solid dash, a path not closed, and a width of 2 points (.00706 meters or 2/72 inches.) The bounding box is the axis-aligned box surrounding the points of the polyline, extended, to guarantee enclosure, by half of the width of the polyline.

Return Value:

Returns the ImageBvr object.

ParameterDescription
points The Point2Bvr object defining the endpoints of the line segments to draw.
col The ColorBvr object.


solidColorImage

public static ImageBvr solidColorImage(ColorBvr col);

Creates an image behavior and applies the given color behavior to all points in the image. The bounding box of a solid-color image is the infinite bounding box.

Return Value:

Returns the ImageBvr object.

ParameterDescription
col The ColorBvr object.


strokeImage

public static ImageBvr strokeImage(Path2Bvr path, LinestyleBvr style, ColorBvr color);

Creates an image behavior and applies the given color behavior to the points in the image that are within the line segments drawn using the given path and line style. The bounding box is the axis-aligned box surrounding the points of the path extended, to guarantee enclosure, by half of the width of the stroke.

Return Value:

Returns the ImageBvr object.

ParameterDescription
path The Path2Bvr object defining the endpoints of the line segments to draw.
style The LinestyleBvr object defining the style to use when drawing the line.
col The ColorBvr object.


Fields

emptyImage
An image behavior (ImageBvr object) in which all points are transparent and undetectable. This has a nullary bounding box, which means that its maximum point is less than its minimum point. This allows operations such as union and intersection to produce the correct results.
detectableEmptyImage
An image behavior (ImageBvr object) in which all points are transparent but detectable. This image is useful for blocking mouse input from underlying image, allowing that input to be redirected. The bounding box is of infinite extent.


Top© 1997 Microsoft Corporation. All rights reserved. Legal Notices.