February 23 - 27, 2009 CSE 113 B
Announcements 2/27: Go over Exam 2 Review Sheet 2/27: Lab 2 due by 11:59:59pm 3/2: Exam 2 3/4: Go over Exam 2 3/6: Exam 2 Makeup
Remove all the red from a picture public void removeRed() { for(int x = 0; x < _p.getWidth(); x++) { for(int y = 0; y < _p.getHeight(); y++) { Pixel pixel = _p.getPixel(x, y); // Simply set the red component of each // pixel to 0. pixel.setRed(0); }
Create the negative of a picture public void createNegative() { for(int x = 0; x < _p.getWidth(); x++) { for(int y = 0; y < _p.getHeight(); y++) { Pixel pixel = _p.getPixel(x, y); // Create a new red value that is // 255 - current red value int redValue = 255 - pixel.getRed(); // Create a new green value that is // 255 - current green value int greenValue = 255 - pixel.getGreen(); // Create a new blue value that is // 255 - current blue value int blueValue = 255 - pixel.getBlue();
Create the negative of a picture (cont.) // Create a new color based on our new red, green, // and blue values java.awt.Color newColor = new java.awt.Color (redValue,greenValue,blueValue); // Set the color of the pixel to that new color pixel.setColor(newColor); }
Wednesday & Friday Class Wednesday: In-class exercise on loops Friday: Go over Exam 2 Review Sheet (Answers posted online)