public class Picture extends SimplePicture
Constructor and Description |
---|
Picture()
Constructor that takes no arguments
|
Picture(java.awt.image.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(java.lang.String fileName)
Constructor that takes a file name and creates the picture
|
Modifier and Type | Method and Description |
---|---|
static float |
averageColors(java.util.ArrayList<Pixel> pixels,
int colorNum)
Averages the chosen color for all the pixels in an ArrayList.
|
void |
blueScreen(Picture target,
int targetX,
int targetY)
Method to do chromakey assuming a blue background
|
void |
chromakey(Picture target,
java.awt.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
|
static int |
getColor(Pixel pixel,
int colorNum)
Gets the value of the color corresponding to colorNum.
|
void |
grayscaleWithLuminance()
Method to change the picture to gray scale with luminance
|
void |
increaseRed()
Method to increase the red in a picture.
|
static void |
main(java.lang.String[] args) |
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
|
void |
reduceTo8()
Reduces the number of colors to 8 by picking two values for red,
two for green, and two for blue.
|
Picture |
scale(double factor)
Method to scale the picture by a factor, and return the result
|
static void |
setColor(Pixel pixel,
int newValue,
int colorNum)
Sets the value of the color corresponding to colorNum to newValue.
|
static Picture |
showNamed(java.lang.String fileName)
Class method to create a picture object from the passed file name and
then show it
|
java.lang.String |
toString()
Method to return a string with information about this picture.
|
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
public Picture()
public Picture(java.lang.String fileName)
fileName
- the name of the file to create the picture frompublic Picture(int width, int height)
width
- the width of the desired pictureheight
- the height of the desired picturepublic Picture(Picture copyPicture)
copyPicture
- the picture to be copiedpublic Picture(java.awt.image.BufferedImage image)
image
- the buffered image to usepublic java.lang.String toString()
toString
in class SimplePicture
public static Picture pickAndShow()
public static Picture showNamed(java.lang.String fileName)
fileName
- the name of the file that has a picture in itpublic Picture copy()
public void increaseRed()
public void negate()
public Picture flip()
public void decreaseRed()
public void decreaseRed(double amount)
amount
- the amount to change the red bypublic void compose(Picture target, int targetX, int targetY)
target
- the picture onto which we copy this picturetargetX
- target X position to start attargetY
- target Y position to start atpublic Picture scale(double factor)
factor
- the factor to scale by (1.0 stays the same,
0.5 decreases each side by 0.5, 2.0 doubles each side)public void chromakey(Picture target, java.awt.Color bgColor, int threshold, int targetX, int targetY)
target
- the picture onto which we chromakey this picturebgColor
- the color to make transparentthreshold
- within this distance from bgColor, make transparenttargetX
- target X position to start attargetY
- target Y position to start atpublic void blueScreen(Picture target, int targetX, int targetY)
target
- the picture onto which we chromakey this picturetargetX
- target X position to start attargetY
- target Y position to start atpublic void grayscaleWithLuminance()
public Picture oilPaint(int dist)
dist
- the distance from the current pixel
to use in the rangepublic void reduceTo8()
public static int getColor(Pixel pixel, int colorNum)
pixel
- the pixel whose color is returnedcolorNum
- the color to choose: 1 = red, 2 = green, 3 = bluepublic static void setColor(Pixel pixel, int newValue, int colorNum)
pixel
- the pixel whose color is setnewValue
- the new value for the colorcolorNum
- the color to choose: 1 = red, 2 = green, 3 = bluepublic static float averageColors(java.util.ArrayList<Pixel> pixels, int colorNum)
pixels
- the list of pixels to be averagedcolorNum
- the color to average: 1 = red, 2 = green, 3 = bluepublic static void main(java.lang.String[] args)