|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSimplePicture
Picture
public class Picture
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
Constructor Summary | |
---|---|
Picture()
Constructor that takes no arguments |
|
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 |
addBox()
Method to add a solid red rectangle to the current picture |
static Picture |
addBoxToBeach()
Method to add a solid red rectangle to the beach picture |
void |
blendPictures()
Method to blend two sisters together onto the current picture |
Picture |
blendPictures(Picture sourcePict,
double sourceAlpha)
Method to blend two pictures, the current picture object and the passed sourcePict object. |
void |
blueChange()
Method to set all blue values to 100 in the picture |
void |
blueOneHundred()
Method to set the blue values to 100 in a rectangle of 100 pixels with x and y starting at 0 and ending at 99 |
void |
blur(int numPixels)
Method to blur the pixels |
void |
changeColors(double redAmount,
double greenAmount,
double blueAmount)
Method to change the color of each pixel in the picture object by passed in amounts. |
void |
changePixelsWithinDistance(Color compareColor,
double distance,
double redFactor,
double greenFactor,
double blueFactor,
int startX,
int startY,
int endX,
int endY)
Method to change all the pixels within a passed distance of a passed color in a range specified by a startX, startY, endX, and endY by passed red, green, and blue factors. |
void |
changeRed(double amount)
Method to change the red by an amount |
void |
changeRedAndGreen(double redMult,
double greenMult)
Method to change the red and green values in the current picture |
void |
chromakey(Picture newBg)
Method to do chromakey using a blue background |
void |
chromakey(Picture newBg,
Color color,
double dist)
Method to do chromakey using the passed background color and the distance to the color |
void |
chromakeyBlue(Picture newBg)
Method to do chromakey using a blue background |
void |
chromakeyRed(Picture newBg)
Method to do chromakey using a red background |
void |
clearBlue()
Method to clear the blue from the picture (set the blue to 0 for all pixels) |
void |
clearBlue2()
Method to clear the blue from the picture (set the blue to 0 for all pixels) |
void |
clearBlue3()
Method to clear the blue from the picture (set the blue to 0 for all pixels) |
void |
clearSomeBlue()
Method to set the blue to zero if the distance from this color to blue is greater than 100 |
Picture |
clipToEllipse()
Method to clip the picture to an ellipse |
Picture |
clipToMessage(String message)
Method to create a new picture from this picture that shows the part of the current picture that is inside a text message |
void |
copy(Picture source,
int x,
int y)
Method to copy the passed picture into the current picture at the given x and y position in the current picture |
void |
copy(Picture sourcePicture,
int startX,
int startY,
int endX,
int endY,
int targetStartX,
int targetStartY)
Method to copy from the passed source picture to the current picture object The copying will start at startX, startY, and end at endX-1 and endY-1 The copy will be placed starting at targetStartX, targetStartY |
void |
copy2D(Picture source,
int x,
int y)
Method to copy the passed picture into the current picture at the given x and y position in the current picture |
void |
copyFlowerLarger()
Method to copy a flower but scaled to 2x normal size onto the current picture |
void |
copyFlowers()
Method to copy flower pictures to create a collage. |
void |
copyFlowersBetter()
Method to copy two flowers in a pattern to the bottom (5 pixels from bottom) of the current picture |
void |
copyFlowerSmaller()
Method to copy the flower but smaller (half as big) on to the current picture |
void |
copyJakitaSmaller()
Method to copy the picture of Jakita but smaller (half as big) to the current picture |
void |
copyKatie()
Method to copy the picture of Katie to the upper left corner of the current picture |
void |
copyKatieLeftRotation()
Method to copy the picture of Katie but rotate her left 90 degrees on the current picture |
void |
copyKatieMidway()
Method to copy the picture of Katie to (100,100) in the current picture |
void |
copyKatiesFace()
Method to copy just Katie's face to the current picture |
void |
copyNonWhitePixels(Picture sourcePicture,
int startX,
int startY,
int endX,
int endY,
int targetStartX,
int targetStartY)
Method to copy from the passed source picture to the current picture object The copying will start at startX, startY, and end at endX-1 and endY-1 The copy will be placed starting at targetStartX, targetStartY |
void |
copyPicture(Picture sourcePict,
Rectangle sourceRect,
Rectangle targetRect,
Composite composite)
Method to copy a picture into the current picture using the passed composite rule |
void |
copyPictureTo(Picture sourcePicture,
int xStart)
Method that will copy all of the passed source picture into the current picture object starting with the left corner given by xStart. |
void |
copyPictureTo(Picture sourcePicture,
int xStart,
int yStart)
Method that will copy all of the passed source picture into the current picture object starting with the left corner given by xStart, yStart |
void |
copyRobot()
Method to copy the picture of a robot to the 100,100 of the current picture |
int |
countWhitePixels()
Method to count the number of white pixels in a picture |
static Picture |
createComposite()
Method to try different composite rules in a picture with a gradient painted rectangle and a texture painted ellipse |
void |
darken()
Method to darken the color in the picture |
void |
decreaseBlue()
Method to decrease the blue in the picture by 30% |
void |
decreaseGreen()
Method to decrease the green in the picture by 30% |
void |
decreaseRed()
Method to decrease the red by half in the current picture |
Picture |
decreaseRedI()
Method to decrease the red by half in a copy of the current picture |
void |
doubleRedInRange(int startX,
int startY,
int endX,
int endY,
double distance,
Color compareColor)
Method to double the red in a picture in a rectangular area if it is less than the passed distance to the passed color |
void |
drawBox(Color color,
int topLeftX,
int topLeftY,
int width,
int height)
Method to draw a filled box on the current picture |
void |
drawExample()
Method to show different drawing capabilities. |
void |
drawFace()
Method to draw a face to demonstrate drawing ovals and arcs |
void |
drawFilledRectangles()
Method to draw a picture with a succession of filled rectangles with the top left corner the darkest and the bottom right the lightest on the current picture |
void |
drawGrayEffect()
Method to draw a gray effect picture on the current picture |
void |
drawGrid()
Method to draw a grid on a picture |
void |
drawHorizontalCenteredString(String text,
int y)
Method to draw a horizontally centered string on the current picture |
void |
drawRectangles()
Method to draw a picture with a succession of rectangles on the current picture |
void |
drawString(String text,
int x,
int y)
Method to draw a string on the current picture |
void |
drawSun(int x,
int y,
int width,
int height)
Method to add a gradient painted sun to the current picture |
void |
drawWideX(Color color,
float width)
Method to add two crossed lines to a picture. |
void |
drawX(Color color)
Method to add two crossed lines to a picture. |
void |
edgeDetection(double amount)
Method to do a simple edge detection by comparing the absolute value of the difference between the color intensities (average of the color values) between a pixel and the pixel below it. |
void |
grayscale()
Method to change the picture to gray scale |
void |
grayscaleWithLuminance()
Method to change the picture to gray scale with luminance |
void |
highlightLightAndDark(double amount,
Color replacementColor)
Method to replace the pixel colors in the current picture object that have a color distance less than the passed amount to white or black with the passed replacement color |
void |
increaseRed()
Method to increase the amount of red by 30% |
void |
increaseRed2()
Method to increase the amount of red by 1.3 in the current picture |
void |
increaseRed3()
Method to increase the amount of red by 1.3 in the current picture |
void |
lighten()
Method to lighten the colors in the picture |
void |
lighten(Color compColor,
double distance,
int numTimes)
Method to lighten the colors in the picture if the distance to the passed color is within the passed distance |
void |
makeSunset()
Method to simulate a sunset by decreasing the green and blue |
void |
makeSunset(double reduction)
Method to simulate a sunset by decreasing the green and blue |
void |
makeSunset2()
Method to make a picture look like it was taken at sunset by reducing the blue and green to make it look more red |
static void |
makeTurtleMovie()
Method to show a turtle crawling across the beach |
void |
mirrorHorizontal()
Method to mirror around a horizontal line in the middle based on the height. |
void |
mirrorHorizontalBottomToTop()
Method to mirror around a horiztonal line in the middle based on the height of the picture. |
void |
mirrorTemple()
Method to mirror part of the temple picture around a vertical line at a mirror point |
static Picture |
mirrorTempleS3()
Method to mirror the piedmont of the temple |
void |
mirrorVertical()
Method to mirror around a vertical line in the middle of the picture based on the width |
void |
negate()
Method to negate the picture |
void |
overlapPictures(Picture p1,
Picture p2,
int startOverlap)
Method to overlap one picture with another horizontally on top of the current picture. |
static Picture |
pickAndShow()
Method to allow the user to pick a file name and show a picture. |
void |
posterize()
Method to posterize (reduce the number of colors) in the picture. |
void |
posterize(int numLevels)
Method to posterize (reduce the number of colors) in the picture |
void |
removeRedEye(int startX,
int startY,
int endX,
int endY,
Color newColor)
Method to remove red eye from the current picture object in the rectangle defined by startX, startY, endX, endY. |
Picture |
rotate(int degrees)
Method to create a new picture by rotating the current picture by the given degrees |
Picture |
scale(double xFactor,
double yFactor)
Method to create a new picture by scaling the current picture by the given x and y factors |
Picture |
scaleUp(int numTimes)
Method to create a new picture that is scaled up by the passed number of times. |
void |
sepiaTint()
Method to change the current picture to a sepia tint (modify the middle colors to a light brown and the light colors to a light yellow and make the shadows darker) |
void |
setBlue()
Method to set the blue to zero if the current blue value is greater than 100 |
void |
setRedToBlue()
Method to set the red to the blue value |
Picture |
shear(double xFactor,
double yFactor)
Method to create a new picture by shearing the current picture by the given x and y factors |
static Picture |
showNamed(String fileName)
Method to show a picture created from a passed file name |
static Picture |
showSpecificPicture()
Method to show a specific picture where the file name to show is specified in the method. |
static void |
showTurtleMovie()
Method to show a turtle crawling across the beach |
void |
swapBackground(Picture oldBackground,
Picture newBackground)
Method to replace the background in the current picture with the background from another picture |
void |
swapBackground(Picture oldBackground,
Picture newBackground,
double threshold)
Method to replace the background in the current picture with the background from another picture |
String |
toString()
Method to return a string with information about this picture. |
void |
turnBrownIntoRed()
Method to turn the brown in a picture into red |
void |
turnBrownToRedInRectangle()
Method to turn brown to red inside of a rectangular area |
void |
turnBrownToRedInRectangle(int startX,
int endX,
int startY,
int endY)
Method to turn brown to red in a rectangular area specifed by startX, endX-1, startY, endY-1 |
void |
turnBrownToRedInRectangle(int startX,
int endX,
int startY,
int endY,
double distance)
Method to turn brown to red in a rectangular area specifed by startX, endX-1, startY, endY-1 |
Methods inherited from class SimplePicture |
---|
addMessage, copyPicture, createGraphics, explore, getBasicPixel, getBufferedImage, getExtension, getFileName, getGraphics, getHeight, getImage, getMediaPath, getPictureFrame, getPictureWithHeight, getPixel, getPixels, getTitle, getTransformEnclosingRect, getWidth, hide, load, load, loadPictureAndShowIt, repaint, setAllPixelsToAColor, setBasicPixel, setMediaPath, setPictureFrame, setTitle, setVisible, show, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Picture()
public Picture(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)
Method Detail |
---|
public String toString()
toString
in class SimplePicture
public static Picture pickAndShow()
public static Picture showSpecificPicture()
public static Picture showNamed(String fileName)
fileName
- the name of the file to create the picture from
public Picture decreaseRedI()
public void decreaseRed()
public void setRedToBlue()
public void changeRedAndGreen(double redMult, double greenMult)
redMult
- the amount to multiply the red bygreenMult
- the amount to multiply the green bypublic void increaseRed()
public void clearBlue()
public void makeSunset()
public void makeSunset(double reduction)
reduction
- the amount to multiply the original values bypublic void decreaseGreen()
public void decreaseBlue()
public void makeSunset2()
public void changeRed(double amount)
amount
- the amount to change the red bypublic void changeColors(double redAmount, double greenAmount, double blueAmount)
redAmount
- the amount to change the red valuegreenAmount
- the amount to change the green valueblueAmount
- the amount to change the blue valuepublic void clearBlue2()
public void clearBlue3()
public void darken()
public void negate()
public void grayscale()
public void grayscaleWithLuminance()
public void increaseRed2()
public void increaseRed3()
public void lighten()
public void lighten(Color compColor, double distance, int numTimes)
compColor
- the color to compare todistance
- the distance from the compare colornumTimes
- the number of times to lightenpublic void mirrorVertical()
public void mirrorHorizontal()
public void mirrorHorizontalBottomToTop()
public void mirrorTemple()
public static Picture mirrorTempleS3()
public void copyKatie()
public void copyRobot()
public void copyKatieMidway()
public void copyKatiesFace()
public void copyFlowers()
public void copyPictureTo(Picture sourcePicture, int xStart)
sourcePicture
- the picture object to copyxStart
- the x position to start the copy in the targetpublic void copyFlowersBetter()
public void copy(Picture sourcePicture, int startX, int startY, int endX, int endY, int targetStartX, int targetStartY)
sourcePicture
- the source picture to copy fromstartX
- the starting x value in the source picturestartY
- the starting y value in the source pictureendX
- the ending x value in the source pictureendY
- the ending y value in the source picturetargetStartX
- the starting x value in the
current picturetargetStartY
- the starting y value in the
current picturepublic void copyNonWhitePixels(Picture sourcePicture, int startX, int startY, int endX, int endY, int targetStartX, int targetStartY)
sourcePicture
- the source picture to copy fromstartX
- the starting x value in the source picturestartY
- the starting y value in the source pictureendX
- the ending x value in the source pictureendY
- the ending y value in the source picturetargetStartX
- the starting x value in the current picturetargetStartY
- the starting y value in the current picturepublic void blendPictures()
public void copyPictureTo(Picture sourcePicture, int xStart, int yStart)
sourcePicture
- the picture object to copyxStart
- the x position to start the copy into on
the targetyStart
- the y position to start the copy into on
the targetpublic void copyKatieLeftRotation()
public void copyFlowerSmaller()
public void copyJakitaSmaller()
public void copyFlowerLarger()
public void turnBrownIntoRed()
public void turnBrownToRedInRectangle()
public void turnBrownToRedInRectangle(int startX, int endX, int startY, int endY)
startX
- the starting location to check in xendX
- the last pixel checked is one less than
this in xstartY
- the starting location to check in yendY
- the last pixel checked is one less than
this in ypublic void turnBrownToRedInRectangle(int startX, int endX, int startY, int endY, double distance)
startX
- the starting location to check in xendX
- the last pixel checked is one less than
this in xstartY
- the starting location to check in yendY
- the last pixel checked is one less than
this in ydistance
- if the current color is within this distance
to brown then change itpublic void doubleRedInRange(int startX, int startY, int endX, int endY, double distance, Color compareColor)
startX
- the x value at the top left of the rectangular
areastartY
- the y value at the top left of the rectangular
areaendX
- the bottom right x value of the rectangular areaendY
- the bottom right y value of the rectangular areadistance
- the amount that the distance must be less thancompareColor
- the color to compare the current pixel
color topublic void changePixelsWithinDistance(Color compareColor, double distance, double redFactor, double greenFactor, double blueFactor, int startX, int startY, int endX, int endY)
compareColor
- the color to compare todistance
- the distance that this should be within
(less than)redFactor
- the amount to multiply the current red
value bygreenFactor
- the amount to multiply the current green
value byblueFactor
- the amount to multiply the current blue
value bystartX
- the starting x value to use in checking the
pixelsstartY
- the starting y value to use in checking the
pixelsendX
- the ending x value to use in checking the
pixels (< this)endY
- the ending y value to use in checking the
pixels (< this)public void removeRedEye(int startX, int startY, int endX, int endY, Color newColor)
startX
- the top left corner x value of a rectanglestartY
- the top left corner y value of a rectangleendX
- the bottom right corner x value of a rectangleendY
- the bottom right corner y value of a rectanglenewColor
- the new color to usepublic void sepiaTint()
public void posterize()
public void posterize(int numLevels)
numLevels
- the number of color levels to usepublic void highlightLightAndDark(double amount, Color replacementColor)
replacementColor
- the new color to usepublic Picture scaleUp(int numTimes)
public void blur(int numPixels)
numPixels
- the number of pixels to average in all
directions. So if the numPixels is 2 then we will average
all pixels in the rectangle defined by 2 before the current
pixel to 2 after the current pixelpublic void edgeDetection(double amount)
amount
- if the absolute value of the differences in the
color average is less than this
set the color to white, else blackpublic void swapBackground(Picture oldBackground, Picture newBackground)
oldBackground
- the old background to replacenewBackground
- the new background to usepublic void swapBackground(Picture oldBackground, Picture newBackground, double threshold)
oldBackground
- the old background to replacenewBackground
- the new background to usethreshold
- if the distance between the current pixel
color and the background
pixel color is less than this amount use the new background
pixel colorpublic void chromakey(Picture newBg, Color color, double dist)
newBg
- the new background image to use to replacecolor
- the background color to compare todist
- the distance that limits the chromakey
it will happen if the distance is less than or equal
to this valuepublic void chromakey(Picture newBg)
newBg
- the new background image to use to replace
the blue from the current picturepublic void chromakeyBlue(Picture newBg)
newBg
- the new background image to use to replace
the blue from the current picturepublic void chromakeyRed(Picture newBg)
newBg
- the new background image to use to replace
the red from the current picturepublic void blueOneHundred()
public void blueChange()
public void clearSomeBlue()
public void setBlue()
public int countWhitePixels()
public void drawGrid()
public void addBox()
public static Picture addBoxToBeach()
public void drawBox(Color color, int topLeftX, int topLeftY, int width, int height)
color
- the color to draw the box withtopLeftX
- the top left x coordinate of the boxtopLeftY
- the top left y coordinate of the boxwidth
- the width of the boxheight
- the height of the boxpublic void drawExample()
public void drawFace()
public void drawString(String text, int x, int y)
text
- the string to drawx
- the x location to start aty
- the y location of the baselinepublic void drawHorizontalCenteredString(String text, int y)
text
- the string to drawy
- the y location of the baselinepublic void drawGrayEffect()
public void drawFilledRectangles()
public void drawRectangles()
public void drawX(Color color)
color
- the color to draw the x inpublic void drawWideX(Color color, float width)
public Picture rotate(int degrees)
degrees
- the number of degrees to rotate by
public Picture shear(double xFactor, double yFactor)
xFactor
- multiplier to use to shift in x
direction based on y indexyFactor
- multiplier to use to shift in y
direction based on x index
public Picture scale(double xFactor, double yFactor)
xFactor
- the amount to scale in xyFactor
- the amount to scale in y
public static Picture createComposite()
public void copy(Picture source, int x, int y)
source
- the picture to copyx
- the x of the upper left corner to copy toy
- the y of the upper left corner to copy topublic void copy2D(Picture source, int x, int y)
source
- the picture to copyx
- the x of the upper left corner to copy toy
- the y of the upper left corner to copy topublic void overlapPictures(Picture p1, Picture p2, int startOverlap)
p1
- the first picture to displayp2
- the second picture to displaystartOverlap
- the x position where the overlap beginspublic void drawSun(int x, int y, int width, int height)
x
- the x location for the upper left corner of the
rectangle enclosing the suny
- the y location for the upper left corner of the
rectangle enclosing the sunwidth
- the width of the enclosing rectangleheight
- the height of the enclosing rectanglepublic Picture clipToEllipse()
public Picture clipToMessage(String message)
message
- the message to show
public Picture blendPictures(Picture sourcePict, double sourceAlpha)
sourcePict
- the source picturesourceAlpha
- the amount of the source picture to use
public void copyPicture(Picture sourcePict, Rectangle sourceRect, Rectangle targetRect, Composite composite)
sourcePict
- the source picture to copy fromsourceRect
- the rectangle that describes what area to
copy fromtargetRect
- the rectangle that describes what area to
copy intocomposite
- the composite to usepublic static void showTurtleMovie()
public static void makeTurtleMovie()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |