12.07.2015 Views

Digital Image Processing (using Java)

Digital Image Processing (using Java)

Digital Image Processing (using Java)

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

(p.79)• usage: java convert infile outfileLISTING 5.6 A simple image format conversion program.public class Convert {public static void main(String[] argv) {if (argv.length > 1) {try {<strong>Image</strong>Decoder input = <strong>Image</strong>File.create<strong>Image</strong>Decoder(argv[0]);Buffered<strong>Image</strong> image = input.decodeAsBuffered<strong>Image</strong>();<strong>Image</strong>Encoder output = <strong>Image</strong>File.create<strong>Image</strong>Encoder(argv[1]);output.encode(image);System.exit(0);}catch (Exception e) {System.err.println(e);System.exit(1);}}else {System.err.println("usage: java Convert ");System.exit(1);}}}(p.85)• usage: java Display imagefileLISTING 5.9 A simple image display application <strong>using</strong> Swing components.import java.awt.*;import java.awt.image.*;import javax.swing.*;import com.pearsoneduc.ip.io.*;public class Display extends JFrame{public Display (String filename){super (filename);<strong>Image</strong>Decoder input = <strong>Image</strong>File.create<strong>Image</strong>Decoder (filename);Buffered<strong>Image</strong> image = input.decodeAsBuffered<strong>Image</strong>();- 11 -

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!