Brighter.java
This is the syntax highlighted version of Brighter.java
from 3.1 Using Data Types of
Introduction to Computer Science by
Robert Sedgewick and Kevin Wayne.
/*************************************************************************
* Compilation: javac Brighter.java
* Execution: java Brighter filename
*
* Reads in an image from a file, and create a brighter version.
*
* % java Brighter image.jpg
*
*************************************************************************/
import java.awt.Color;
public class Brighter {
public static void main(String args[]) {
Picture pic1 = new Picture(args[0]);
int width = pic1.width();
int height = pic1.height();
pic1.show();
Picture pic2 = new Picture(width, height);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
Color c1 = pic1.getColor(x, y);
Color c2 = c1.brighter();
pic2.setColor(x, y, c2);
}
}
pic2.show();
pic2.save(args[1]);
}
}
Last updated: Tue Jun 15 16:36:25 EDT 2004
.
Copyright © 2004, Robert Sedgewick and Kevin Wayne.