acm.graphics
Class GImage

GObject
   extended by GImage

The GImage class is a graphical object whose appearance is defined by an image, which is either loaded from a file or created from a pixel array.


Constructor Summary
GImage(filename)
Creates a new GImage object by reading an image from the specified file.
GImage(array)
Creates a new GImage object from an array of pixels.
 
Method Summary
set_bounds(x, y, width, height)
Changes the bounds of this object to the specified values.
set_image(filename)
Resets the image used by this GImage object to the new image specified as an argument.
set_size(width, height)
Changes the size of this object to the specified width and height.
 
Static Method Summary
get_red(pixel)
Returns the red component of the specified pixel value.
get_green(pixel)
Returns the green component of the specified pixel value.
get_blue(pixel)
Returns the blue component of the specified pixel value.
get_alpha(pixel)
Returns the alpha component of the specified pixel value, which indicates its transparency.
create_rgb_pixel(red, green, blue)
Creates a new opaque pixel value from the three color components.
create_rgb_pixel(alpha, red, green, blue)
Creates a new pixel value from the transparency value and the three color components.
 
Inherited Method Summary
contains(x, y)
Checks to see whether a point is inside the object.
get_bounds()
Returns the bounding box for this object.
get_color()
Returns the color used to display this object.
get_height()
Returns the height of this object, which is defined to be the height of the bounding box.
get_location()
Returns the location of this object as a GPoint.
get_size()
Returns the size of the bounding box for this object.
get_width()
Returns the width of this object, which is defined to be the width of the bounding box.
get_x()
Returns the x-coordinate of the object.
get_y()
Returns the y-coordinate of the object.
is_visible()
Checks to see whether this object is visible.
move(dx, dy)
Moves the object on the screen using the displacements dx and dy.
move_polar(r, theta)
Moves the object using displacements given in polar coordinates.
scale(sf)
Scales the object on the screen by the scale factor sf, which applies in both dimensions.
send_backward()
Moves this object one step toward the back in the z dimension.
send_forward()
Moves this object one step toward the front in the z dimension.
send_to_back()
Moves this object to the back of the display in the z dimension.
send_to_front()
Moves this object to the front of the display in the z dimension.
set_color(color)
Sets the color used to display this object.
set_location(x, y)
Sets the location of this object to the point (x, y).
set_visible(flag)
Sets whether this object is visible.
 

Constructor Detail

GImage(filename)

Creates a new GImage object by reading an image from the specified file.
Usage: gimage = new GImage(filename); 
Parameter: 
filename  The name of the image file
 


GImage(array)

Creates a new GImage object at the origin. The array parameter is a two-dimensional pixel array in which each pixel value consists of an integer that is subdivided into four eight-bit bytes, as follows:
alpha << 24 | red << 16 | green << 8 | blue
The alpha value indicates the transparency, and the other values are the red, green, and blue components of the color.
Usage: image = GImage(arrau); 
Parameter: 
array  The pixel array
 


Method Detail

set_image(filename)

Resets the image used by this GImage object to the new image specified as an argument. Calling set_image automatically changes the size of the image to be equal to that of the image data.
Usage: gimage.set_image(image); 
Parameter: 
filename  The name of the new image file
 


set_bounds(x, y, width, height)

Changes the bounds of this GImage to the specified values.
Usage: gobj.set_bounds(x, y, width, height) 
Parameters: 
 The new x-coordinate for the object
 The new y-coordinate for the object
width  The new width of the object
height  The new height of the object
 


set_size(width, height)

Changes the size of this object to the specified width and height.
Usage: gobj.set_size(width, height) 
Parameters: 
width  The new width of the object
height  The new height of the object
 


get_red(pixel)

Returns the red component of the specified pixel value.
Usage: GImage.get_red(pixel) 
Parameter: 
pixel  The pixel value as an integer
Returns: The red component of this pixel in the range 0 to 255.
 


get_green(pixel)

Returns the green component of the specified pixel value.
Usage: GImage.get_green(pixel) 
Parameter: 
pixel  The pixel value as an integer
Returns: The green component of this pixel in the range 0 to 255.
 


get_blue(pixel)

Returns the blue component of the specified pixel value.
Usage: GImage.get_blue(pixel) 
Parameter: 
pixel  The pixel value as an integer
Returns: The blue component of this pixel in the range 0 to 255.
 


get_alpha(pixel)

Returns the alpha component of the specified pixel value, which indicates its transparency.
Usage: GImage.get_alpha(pixel) 
Parameter: 
pixel  The pixel value as an integer
Returns: The alpha component of this pixel in the range 0 to 255.
 


create_rgb_pixel(red, green, blue)

Creates a new opaque pixel value from the three color components.
Usage: GImage.create_rgb_pixel(red, green, blue) 
Parameters: 
red  The red component of the pixel.
green  The green component of the pixel.
blue  The blue component of the pixel.
Returns: The new pixel value.
 


create_rgb_pixel(alpha, red, green, blue)

Creates a new opaque pixel value from the transparency and the three color components.
Usage: GImage.create_rgb_pixel(alpha, red, green, blue) 
Parameters: 
alpha  The transparency of the pixel.
red  The red component of the pixel.
green  The green component of the pixel.
blue  The blue component of the pixel.
Returns: The new pixel value.