Package picasso.model
Class Pixmap
- java.lang.Object
-
- picasso.model.Pixmap
-
public class Pixmap extends Object
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/95Ported: 10/16/1996 to Java (Syam Gadde) re-implemented, ported to 1.1 6/1/97 (Owen Astrachan)
-
-
Field Summary
Fields Modifier and Type Field Description static Color
DEFAULT_COLOR
static String
DEFAULT_NAME
static Dimension
DEFAULT_SIZE
BufferedImage
myImage
Dimension
mySize
-
Constructor Summary
Constructors Constructor Description Pixmap()
Create a default pixmap (300x300 black)Pixmap(int width, int height)
Create a black pixmap with given width and heightPixmap(int width, int height, Color color)
Create a pixmap with given width and height and filled with given initial colorPixmap(Dimension size)
Create a black pixmap with given sizePixmap(String fileName)
Create a pixmap from the given local filePixmap(Pixmap other)
Create this image as a copy of the given image
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 colorString
getName()
Returns the name of the imageDimension
getSize()
boolean
isInBounds(int x, int y)
Determine if the given (x,y) coordinate is within the bounds of this image.void
paint(Graphics pen)
void
read(String fileName)
Read the image named by fileNamevoid
setColor(int x, int y, Color value)
void
setSize(int width, int height)
Changes the size of the image to the given width and heightvoid
setSize(Dimension size)
void
write(String fileName)
Write the current image to a file as a jpg.
-
-
-
Field Detail
-
DEFAULT_SIZE
public static final Dimension DEFAULT_SIZE
-
DEFAULT_COLOR
public static final Color DEFAULT_COLOR
-
DEFAULT_NAME
public static final String DEFAULT_NAME
- See Also:
- Constant Field Values
-
myImage
public BufferedImage myImage
-
mySize
public Dimension mySize
-
-
Constructor Detail
-
Pixmap
public Pixmap()
Create a default pixmap (300x300 black)
-
Pixmap
public Pixmap(Dimension size)
Create a black pixmap with given size
-
Pixmap
public Pixmap(int width, int height)
Create a black pixmap with given width and height
-
Pixmap
public Pixmap(int width, int height, Color color)
Create a pixmap with given width and height and filled with given initial color
-
Pixmap
public Pixmap(Pixmap other)
Create this image as a copy of the given image
-
Pixmap
public Pixmap(String fileName)
Create a pixmap from the given local file- Parameters:
fileName
- complete pathname of local file
-
-
Method Detail
-
getName
public String 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
public Dimension getSize()
-
getColor
public 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 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
public void setColor(int x, int y, Color value)
-
setSize
public void setSize(Dimension size)
-
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
public void read(String fileName)
Read the image named by fileName- Parameters:
fileName
- the name of the image file to be read in
-
write
public void write(String fileName)
Write the current image to a file as a jpg.- Parameters:
fileName
- the name of the file to write the image to
-
paint
public void paint(Graphics pen)
-
-