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/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 Details

  • Constructor Details

    • 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 Details

    • 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 coordinate
      y - 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 coordinate
      y - 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 image
      height - 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)
    • createImage

      private void createImage(int width, int height, Color color)
    • copyImage

      private BufferedImage copyImage(Dimension from, Dimension to, BufferedImage original)