GraphicsImage Class Reference

« ImageWindow | ReferenceGuide | GraphicsMenu »

This class defines an RGB digital image that is comprised of a grid of pixels divided into rows and columns with (0,0) being in the upper-left corner. The x-coordinate indicates a horizontal position in the image while the y-coordinate indicates a vertical position. Each pixel, which can be accessed by row and column coordinates, contains a color in the discrete RGB color space. An RGB color is represented by three color components: red, green, and blue. Each color component has a discrete value in the range [0..255].

Public Methods

GraphicsImage(filename)
Creates a new graphics image from the given file.
GraphicsImage(width, height)
Creates a new image of the given size.
clear()
Clears the image.
copy()
Creates and returns a duplicate copy of the image.
getBlue(row, col)
Returns the blue component of the RGB color for a given pixel.
getGreen(row, col)
Returns the green component of the RGB color for a given pixel.
getPixel(row, col)
Returns the RGB color of a given pixel as a tuple.
getRed(row, col)
Returns the red component of the RGB color for a given pixel.
height()
Returns the height of the image.
save(filename)
Saves the digital image to the given file.
save(filename, format)
Saves the digital image to a file in the specified format.
setPixel(row, col, red, green, blue)
Sets a pixel to a given RGB color.
setPixel(row, col, hexColor)
Sets a pixel to a given RGB color.
setPixel(row, col, color)
Sets a pixel to a given RGB color.
width()
Returns the width of the image.

Detailed Description

GraphicsImage(filename)
v2.0
Creates a new graphics image from the given file. The image file format can either be GIF or PPM.
GraphicsImage(width, height)
v2.0
Creates a new image of the given size. The image is initially empty and has a size of width x height.
width()
v2.0
Returns the width of the image.
Returns:
The image width given in number of pixels.
See Also:
height()
height()
v2.0
Returns the height of the image.
Returns:
The image height given in number of pixels.
See Also:
width()
setPixel(row, col, red, green, blue)
v2.0
Sets a pixel to a given RGB color. The pixel within the image specified by the given row and column is set to the given RGB color.
Parameters:
row, col
The pixel coordinates.
red, green, blue
The discrete RGB color components given as integers in the range [0..255].
setPixel(row, col, hexColor)
v2.0
Sets a pixel to a given RGB color. The pixel within the image indicated by the given row and column is set to the RGB color specified as a hex string.
Parameters:
row, col
The pixel coordinates.
hexColor
The RGB color specified as a string in hex notation. The string must be in the format #rrggbb where rr, gg, bb are the red, green, and blue components in the range [0..255], but specified in hexadecimal notation.
setPixel(row, col, color)
v2.0
Sets a pixel to a given RGB color. The pixel within the image indicated by the given row and column is set to the RGB color specified as a tuple of 3 elements.
Parameters:
row, col
The pixel coordinates.
hexColor
The RGB color specified as a 3-tuple (red, green, blue) of discrete values in the range [0..255].
getPixel(row, col)
v2.0
Returns the RGB color of a given pixel as a tuple. The color is returned in a tuple of 3 elements with the red value in position 0, the green value in position 1, and the blue value in position 2.
Parameters:
row, col
The pixel coordinates.
Returns:
An RGB color in a tuple of 3 elements.
getRed(row, col)
v2.0
Returns the red component of the RGB color for a given pixel.
Parameters:
row, col
The pixel coordinates.
Returns:
The value of the red component of the given pixel.
See Also:
getGreen() and getBlue()
getGreen(row, col)
v2.0
Returns the green component of the RGB color for a given pixel.
Parameters:
row, col
The pixel coordinates.
Returns:
The value of the green component of the given pixel.
See Also:
getRed() and getBlue()
getBlue(row, col)
v2.0
Returns the blue component of the RGB color for a given pixel.
Parameters:
row, col
The pixel coordinates.
Returns:
The value of the blue component of the given pixel.
See Also:
getRed() and getGreen()
clear()
v2.0
Clears the image. All of the pixels are set to be transparent, but the size of the image remains the same.
copy()
v2.0
Creates and returns a duplicate copy of the image.
Returns:
A GraphicsImage object containing the new duplicate copy.
save(filename)
v2.0
Saves the digital image to the given file. The image is saved in the GIF image format.
Parameters:
filename
A string containing the full name of the GIF image file.
save(filename, format)
v2.0
Saves the digital image to a file in the specified format. The image contained in the window will be saved to the given file using the indicated format.
Parameters:
filename
A string containing the full name of the GIF or PPM image file.
format
A string indicating the format in which to save the image. It can be one of the following values:
ValueDescription
"gif"Save the image in the GIF format.
"ppm"Save the image in the PPM format.


« ImageWindow | ReferenceGuide | GraphicsMenu »

Last modified: August 02, 2015, at 03:21 PM.