Picture methods Lab8 that displays the picture at
T:/Harcourt/Spring2008/CS140/gallery/bug.jpg
Hint: You need to create a Lab8
class with a main method, then build a string object with the
file name above, then build a picture object, then show it. We've done this many times
in previous labs; this should be straightforward by now.
getHeight() on the picture object reference.
In your main method use a println statement to print the height of the bug
picture.
Print a nice message such as Height is _____ where the correct
height of the
bug picture appears where the _____ is.
size. What type should size
be? Think about whether it has a decimal part or not.
size variable.
Picture copy = new Picture(100, 200);
Create and then show a blank picture that is 200 pixels wide and 300 pixels high.
getHeight() and getWidth()
and pass those values to the
Picture constructor.
copyPicture that we went over at the
beginning of today's class.
public void copyPicture(Picture p) {
for (int i = 0; i < this.getWidth(); i++) {
for (int j = 0; j < this.getHeight(); j++) {
Color c = this.getPixel(i,j).getColor();
p.getPixel(i,j).setColor(c);
}
}
}
Copy this method into your Picture class in Picture.java.
copyPicture method on the original bug picture object passing the blank
picture as a parameter.