Problems


[Page 170 (continued)]

5.1

What do the following mean?

  • Overloading

  • Nested Loop

  • Debug


  • [Page 171]
  • Rotate

  • Scale

  • Parameter

  • void

  • return

5.2

Modify any of the methods from the last chapter to use a nested loop. Run it to make sure it still works.

5.3

Take a picture of a person and mirror just their top part to their bottom part (two heads, with one at either end).

5.4

Take a picture of a person and mirror it so that the person looks like conjoined twins.

5.5

Create a new method that will blend two pictures with 10% from just the first picture and a 80% overlap and then 10% from just the last picture. It helps if the two pictures are the same width and height.

5.6

Create a new method that will blend two pictures with 20% from just the first picture and a 60% overlap and then 20% from just the last picture. It helps if the two pictures are the same width and height.

5.7

Modify Program 5 (page 97) to take the amount to reduce red by as a parameter.

5.8

Modify Program 22 (page 139) to be more general by passing in the start and stop x and y and the mirror point in x.

5.9

Convert the method copyFlowerLarger() (Program 31 (page 162)) to a method that can scale any picture up to twice the original width and height. It should return a new picture object created using new Picture(this.getWidth() * 2,this.getHeight() * 2).

5.10

Write a method to flip a picture over so that things that were on the left are now on the right. You probably want to create a new picture and copy the pixels from a passed-in picture to the new picture. Return the new picture.

5.11

Modify Program 29 (page 158) in this chapter to take the source picture to rotate and to create a new picture of just the needed size. Return the new picture.

5.12

Write a method to mirror a picture around a horizontal line from (0, height-1) to (width-1, height-1). Be aware that this will double the height of the picture.

5.13

Write a method to mirror a picture around a vertical line from (width-1, 0) to (width-1, height-1). Be aware that this will double the width of the picture.

5.14

Try to mirror a picture around a diagonal line from (0, 0) to (width-1, height-1). Try to mirror a picture around a diagonal line from (0, height-1) to (width-1, 0).

5.15

Write a method to rotate a picture to the right by 90 degrees.

5.16

Write a method to rotate a picture to the right by 180 degrees.


[Page 172]
5.17

All of our copy methods copy rectangular areas. Try to write a copy method that copies a triangular area. Write one that copies a circular area.

5.18

We've seen that if you increment the source picture index by 2 while incrementing the target picture index by 1 for each copied pixel, you end up with the source being scaled down onto the target. What happens if you increment the target picture index by 2 as well? What happens if you increment both the source and target by 0.5 and use int to get just the integer part?

5.19

Write a method named createCollage to create a collage of the same image at least four times onto the 7x95in.jpg blank JPEG. (You are welcome to add additional images, too.) One of those four copies can be the original picture. The other three should be modified forms. You can do any of scaling, cropping, or rotating the image; creating a negative of the image; shifting or altering colors on the image; and making it darker or lighter. After composing your image, mirror it. You can do it vertically or horizontally (or otherwise), in any directionjust make sure that your four base images are visible still after mirroring.

Your single method should make all of this happenall of the effects and compositing must occur from the single function createCollage. Of course, it is perfectly okay to use other functions, but make it so that a tester of your program need only to call setMediaPath() and put all your input pictures in her mediasources directory, create a Picture object from the blank papersized file, and then execute createCollage()and will expect to have a collage generated and returned.

5.20

Think about how the grayscale algorithm works. Basically, if you know the luminance of anything visual (e.g., a small image, a letter), you can replace a pixel with that visual element in a similar way to create a collage image. Try implementing that. You'll need 256 visual elements of increasing lightness, all of the same size. You'll create a collage by replacing each pixel in the original image with one of these visual elements.



Introduction to Computing & Programming Algebra in Java(c) A Multimedia Approach
Introduction to Computing & Programming Algebra in Java(c) A Multimedia Approach
ISBN: N/A
EAN: N/A
Year: 2007
Pages: 191

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net