/** * Class for creating a template for a simple Java program * * @author Pat Troy: troy AT uic DOT edu */ // import the library with the color information import java.awt.Color; // Note the name of the class in the following line MUST // match the name of the file. This is stored in a file // named: Template.java public class Lect105c { public static void main (String[] args) { System.out.println("Begin Java Exection"); System.out.println(""); // Select a picture for the turtle to draw on String filename = FileChooser.pickAFile(); System.out.println (filename); Picture pict1 = new Picture(filename); int width = pict1.getWidth(); int height = pict1.getHeight(); System.out.println ("Width: " + width); System.out.println ("Height: " + height); // set up a nested loop (one loop inside another) to access each pixel int xLoopCounter; int yLoopCounter; xLoopCounter = 0; while (xLoopCounter < width) { yLoopCounter = 0; while (yLoopCounter < height) { // access a pixel Pixel p = pict1.getPixel (xLoopCounter, yLoopCounter); int red = p.getRed(); int green = p.getGreen(); int blue = p.getBlue(); green = (int)(green * 0.5); blue = (int)(blue * 0.5); p.setGreen(green); p.setBlue(blue); yLoopCounter++; } xLoopCounter++; } // display the picture pict1.explore(); // Save the picture //String fname; //fname = FileChooser.pickAFile(); //System.out.println ("File: " + filename); //pict1.write (fname); System.out.println(""); System.out.println("End Java Exection"); } // end of the method main } // end of Lect914b class