CS 140 - Lab 9 Instructions

Objectives

  1. More practice with for-loops
  2. Experiment with new picture methods
  3. Learn how to place several pictures into a larger picture creating a collage.

Method

Part I - Copying a picture to a particular location

  1. Make an empty Lab9 program with a main method.
  2. Add code to show the picture named bug_small.jpg. Recall that you need the full path to the picture. Where is it?
  3. Create a new picture object collage that is blank with dimensions 1024 pixels wide by 768 pixels high. Show it. Once you are sure it shows a blank image properly comment out the line that shows it, so we don't keep showing a copy of the blank image.
  4. Use the copyPicture method from lab 8 to copy the picture of the bug into the collage and show it.

    Notice that most of the picture is empty space. What we're are going to do now is fill in the empty space with other picures or copies of the same picture creating a collage.

  5. Write a new copyPictureXY method that takes two additional parameters x and y that are the upper left coordinate of where the picture should be copied to. This method goes in Picture.java. Here is an example of how we would call copyPictureXY.
            orig.copyPictureXY(collage, 100, 100);
    						

    This copies orig into collage starting at coordinate (100,100) in collage.

  6. Test your copyPictureXY method by copying another copy of the bug right next to the first bug in the collage.

Part II - Creating a Collage

  1. Add the picture two_fish_small.jpg to your collage. Add it anywhere in the collage.
  2. Add the picture moose_small.jpg to your collage.
  3. Use your grayScale, extractRedChannelRed, extractBlueChannelBlue, and extractRedChannelRed to create a whacked out collage using several pictures from the folder of pictures on the T: drive. Here's mine. (Picture credits below).

Extra Credit

  1. Use the mirrorVertical method from homework 4 in your collage.
  2. Write a method named mirrorHorizontal that is similar to mirrorVertical except that it mirrors the upper half of the image across the horizontal axis.

© Rich Sharp and Ed Harcourt

Picture credits.

http://exultantmood.blogspot.com/2008/02/warning-this-contains-cute-kittens-and.html

http://www.framebox.de/creations/3d/bumblebee/