Objectives:
| Assignment: Modify the program above so that it draws a vertical line and a horizontal line of 25 pixels in the picture starting at (100,100). |
/* Method to return a cropped image
* @params x, y is the upper left hand corner of the sub-image
* @param w is the width of the sub-image
* @param h is the height of the sub-image
* @return a the sub-image at (x,y) of size w by h
*/
public Picture crop(int x, int y, int w, int h){
Picture result = new Picture(w,h);
Pixel pixel;
for (int i = 0, ii=x; i<w; i++,ii++) {
for (int j=0, jj=y; j<h; j++, jj++) {
pixel = result.getPixel(i,j);
pixel.setColor(this.getPixel(ii,jj).getColor());
}
}
return result;
}
Add
this method to the Picture class and try it out.
| Assignment: Write a method for Picture that flips a picture over so that things that were on the left are now on the right. You will want to create a new picture and copy the pixels from the passed-in picture to the new picture. Return the new picture. |
| Assignment: Write a program Collage.java to create a collage of images. Your collage should contain at least 3 images. You may use methods that are described in your text. In addition you must implement at least three additional methods for the Picture class. Here are some suggestions but feel free to think of your own (just clear them with me first).
Many of the methods will create images that
exceed the dimensions of the jpg file. Just ignore these parts
so that the new image stays rectangular. |