Class Picture

java.lang.Object
  extended by SimplePicture
      extended by Picture
All Implemented Interfaces:
DigitalPicture

public class Picture
extends SimplePicture

A class that represents a picture. This class inherits from SimplePicture and allows the student to add functionality to the Picture class. Copyright Georgia Institute of Technology 2004-2008

Author:
Barbara Ericson ericson@cc.gatech.edu

Constructor Summary
Picture()
          Constructor that takes no arguments
Picture(BufferedImage image)
          Constructor that takes a buffered image
Picture(int width, int height)
          Constructor that takes the width and height
Picture(Picture copyPicture)
          Constructor that takes a picture and creates a copy of that picture
Picture(String fileName)
          Constructor that takes a file name and creates the picture
 
Method Summary
 void blueScreen(Picture target, int targetX, int targetY)
          Method to do chromakey assuming a blue background
 void chromakey(Picture target, Color bgColor, int threshold, int targetX, int targetY)
          Method to do chromakey using an input color for the background and a point for the upper left corner of where to copy
 void compose(Picture target, int targetX, int targetY)
          Method to compose (copy) this picture onto a target picture at a given point.
 Picture copy()
          A method create a copy of the current picture and return it
 void decreaseRed()
          Method to decrease the red by half in the current picture
 void decreaseRed(double amount)
          Method to decrease the red by an amount
 Picture flip()
          Method to flip a picture
 void grayscaleWithLuminance()
          Method to change the picture to gray scale with luminance
 void increaseRed()
          Method to increase the red in a picture.
 void negate()
          Method to negate a picture
 Picture oilPaint(int dist)
          Method to do an oil paint effect on a picture
static Picture pickAndShow()
          Class method to let the user pick a file name and then create the picture and show it
 Picture scale(double factor)
          Method to scale the picture by a factor, and return the result
static Picture showNamed(String fileName)
          Class method to create a picture object from the passed file name and then show it
 String toString()
          Method to return a string with information about this picture.
 
Methods inherited from class SimplePicture
addMessage, copyPicture, createGraphics, drawString, explore, getBasicPixel, getBufferedImage, getExtension, getFileName, getGraphics, getHeight, getImage, getMediaPath, getPictureFrame, getPictureWithHeight, getPictureWithWidth, getPixel, getPixels, getTitle, getTransformEnclosingRect, getWidth, hide, load, load, loadImage, loadOrFail, loadPictureAndShowIt, repaint, scale, setAllPixelsToAColor, setBasicPixel, setFileName, setMediaPath, setPictureFrame, setTitle, setVisible, show, write, writeOrFail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Picture

public Picture()
Constructor that takes no arguments


Picture

public Picture(String fileName)
Constructor that takes a file name and creates the picture

Parameters:
fileName - the name of the file to create the picture from

Picture

public Picture(int width,
               int height)
Constructor that takes the width and height

Parameters:
width - the width of the desired picture
height - the height of the desired picture

Picture

public Picture(Picture copyPicture)
Constructor that takes a picture and creates a copy of that picture


Picture

public Picture(BufferedImage image)
Constructor that takes a buffered image

Parameters:
image - the buffered image to use
Method Detail

toString

public String toString()
Method to return a string with information about this picture.

Overrides:
toString in class SimplePicture
Returns:
a string with information about the picture such as fileName, height and width.

pickAndShow

public static Picture pickAndShow()
Class method to let the user pick a file name and then create the picture and show it

Returns:
the picture object

showNamed

public static Picture showNamed(String fileName)
Class method to create a picture object from the passed file name and then show it

Parameters:
fileName - the name of the file that has a picture in it
Returns:
the picture object

copy

public Picture copy()
A method create a copy of the current picture and return it

Returns:
the copied picture

increaseRed

public void increaseRed()
Method to increase the red in a picture.


negate

public void negate()
Method to negate a picture


flip

public Picture flip()
Method to flip a picture


decreaseRed

public void decreaseRed()
Method to decrease the red by half in the current picture


decreaseRed

public void decreaseRed(double amount)
Method to decrease the red by an amount

Parameters:
amount - the amount to change the red by

compose

public void compose(Picture target,
                    int targetX,
                    int targetY)
Method to compose (copy) this picture onto a target picture at a given point.

Parameters:
target - the picture onto which we copy this picture
targetX - target X position to start at
targetY - target Y position to start at

scale

public Picture scale(double factor)
Method to scale the picture by a factor, and return the result

Parameters:
factor - the factor to scale by (1.0 stays the same, 0.5 decreases each side by 0.5, 2.0 doubles each side)
Returns:
the scaled picture

chromakey

public void chromakey(Picture target,
                      Color bgColor,
                      int threshold,
                      int targetX,
                      int targetY)
Method to do chromakey using an input color for the background and a point for the upper left corner of where to copy

Parameters:
target - the picture onto which we chromakey this picture
bgColor - the color to make transparent
threshold - within this distance from bgColor, make transparent
targetX - target X position to start at
targetY - target Y position to start at

blueScreen

public void blueScreen(Picture target,
                       int targetX,
                       int targetY)
Method to do chromakey assuming a blue background

Parameters:
target - the picture onto which we chromakey this picture
targetX - target X position to start at
targetY - target Y position to start at

grayscaleWithLuminance

public void grayscaleWithLuminance()
Method to change the picture to gray scale with luminance


oilPaint

public Picture oilPaint(int dist)
Method to do an oil paint effect on a picture

Parameters:
dist - the distance from the current pixel to use in the range
Returns:
the new picture