Package picasso.model
Class Pixmap
java.lang.Object
picasso.model.Pixmap
Class for manipulating graphics images, originally developed in C++.
This class represents an image that supports manipulation, i.e., reflection, expansion, inversion, etc. It has an analog in C++, for comparison between the two languages, although there is more support in Java for images than there is in C++.
Creating a pixmap requires a filename that should be a gif or jpg image (or others if getImage() supports them). Currently the filename represents a local image, but changing the URL to support network retrievable images should be straightforward.
Revision history for C++ version:
Modified: 3/21/94 11/29/94 4/13/95
Ported: 10/16/1996 to Java (Syam Gadde) re-implemented, ported to 1.1 6/1/97 (Owen Astrachan)
- Author:
- Robert C. Duvall, Owen Astrachan, Syam Gadde
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPixmap()Create a default pixmap (300x300 black)Pixmap(int width, int height) Create a black pixmap with given width and heightCreate a pixmap with given width and height and filled with given initial colorCreate a black pixmap with given sizeCreate a pixmap from the given local fileCreate this image as a copy of the given image -
Method Summary
Modifier and TypeMethodDescriptionprivate BufferedImagecopyImage(Dimension from, Dimension to, BufferedImage original) private voidcreateImage(int width, int height, Color color) getColor(int x, int y) Returns the color of the pixel at the given (x,y) coordinate if the coordinate is within the bounds of the image; otherwise returns the default colorgetName()Returns the name of the imagegetSize()booleanisInBounds(int x, int y) Determine if the given (x,y) coordinate is within the bounds of this image.voidvoidRead the image named by fileNamevoidvoidsetSize(int width, int height) Changes the size of the image to the given width and heightvoidvoidWrite the current image to a file as a jpg.
-
Field Details
-
DEFAULT_SIZE
-
DEFAULT_COLOR
-
DEFAULT_NAME
- See Also:
-
myFileName
-
myImage
-
mySize
-
-
Constructor Details
-
Pixmap
public Pixmap()Create a default pixmap (300x300 black) -
Pixmap
Create a black pixmap with given size -
Pixmap
public Pixmap(int width, int height) Create a black pixmap with given width and height -
Pixmap
Create a pixmap with given width and height and filled with given initial color -
Pixmap
Create this image as a copy of the given image -
Pixmap
Create a pixmap from the given local file- Parameters:
fileName- complete pathname of local file
-
-
Method Details
-
getName
Returns the name of the image- Returns:
- the name of the image
-
isInBounds
public boolean isInBounds(int x, int y) Determine if the given (x,y) coordinate is within the bounds of this image.- Parameters:
x- the x coordinatey- the y coordinate- Returns:
- true if the given (x,y) coordinate is within the bounds of this image.
-
getSize
-
getColor
Returns the color of the pixel at the given (x,y) coordinate if the coordinate is within the bounds of the image; otherwise returns the default color- Parameters:
x- the x coordinatey- the y coordinate- Returns:
- the color of the pixel at the given (x,y) coordinate if the coordinate is within the bounds of the image; otherwise returns the default color
-
setColor
-
setSize
-
setSize
public void setSize(int width, int height) Changes the size of the image to the given width and height- Parameters:
width- the new width of the imageheight- the new height of the image
-
read
Read the image named by fileName- Parameters:
fileName- the name of the image file to be read in
-
write
Write the current image to a file as a jpg.- Parameters:
fileName- the name of the file to write the image to
-
paint
-
createImage
-
copyImage
-