import java.util.InputMismatchException; import java.util.Scanner; import java.awt.Graphics; import java.applet.Applet; import java.util.Random; import java.awt.Color; public class IterationExercises extends Applet { public static void main(String[] args) { manipulatingAnImage(); } /** * Load an image and negate it's pixels. Display the negated image to the user. */ public static void manipulatingAnImage() { // Construct an object of the given Picture class Picture picture = new Picture(); // Use method of the Picture class to load(...) or pick() an image picture.pick(); // Use other methods of the Picture class to negate the image int width = picture.getWidth(); int height = picture.getHeight(); for(int pixH = 0; pixH < height; pixH++) { for(int pixW = 0; pixW < width; pixW++) { Color original = picture.getColorAt(pixW, pixH); int red = 255 - original.getRed(); int green = 255 - original.getGreen(); int blue = 255 - original.getBlue(); Color negative = new Color(red, green, blue); picture.setColorAt(pixW, pixH, negative); } } //while (pixW <= width && pixH <= height) { //Color original = new Color(picture.getColorAt(pixW,pixH), 0, 0); //int red = 255 - original.getRed(pixW,pixH); //int green = 255 - original.getGreen(); //int blue = 255 - original.getBlue(); //Color negative = new Color(red, green, blue); //} what I tried at the start } }