

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Topics To replace one color with another in a picture To conditionally execute a statement or block of statements using an if statement.
Type in the following code in the Program window (changing the comments): import java.awt.Color; /* Program that transforms pictures using loops and conditionals
pix = pixels[index]; // if the color is near brown then double the amount of red if (pix.colorDistance(brown) < 50.0) { pix.setColor(new Color( (int) (pix.getRed() * 2.0), pix.getGreen(), pix.getBlue()) ); } //end if } //end loop } ii) Type in the following code in the Program window in the main method and before the pic.show(); turnBrownIntoRed (sourcePicture); iii) Test your program with different pictures that have brown (e.g. Barbara.jpg). 6.1.3 Reducing Redeye iv) Type in the following code in the Program window below the main method and before the last }: /**