nu.org/licenses/gpl.html).
This class supports the processing of images.
Input image files must be in JPEG format. Output files are written in JPEG format.
Example program, which loads an image from a file dialog, converts it to grayscale, and draws it:
import images.APImage; import images.Pixel; public class TestGrayscale{ public static void main(String[]args){ APImage image = new APImage(); for (Pixel p : image){ int red = p.getRed(); int green = p.getGreen(); int blue = p.getBlue(); int average = (red + green + blue) / 3; p.setRed(average); p.setGreen(average); p.setBlue(average); } image.draw(); } }
You can reset maximum heap size when running the program if you run out of memory for large images, as follows:
java -Xmxnew Sizem programFileName
where
newSize is an integer. For example,
java -Xmx128m TestGrayscale
allows up to 128 megabytes of heap space for the TestGrayscale program.