/* by RPF, 9/29/2001 after * Knudsen Java 2D pg. 183 * and Rodrigues Imagin Apps. pg. 749 * for loading a jpeg into an ImageBuffer. */ // Based primarily on Rodrigues code, pg. 749. // compiled (!) 12:34pm on Hearthside under Java 1.3 // and ran quietly. Good so far. Next look at contents. // Printing the size of tiny.JPG returns w 6 and h 6. import com.sun.image.codec.jpeg.*; import java.awt.image.*; import java.io.*; public class TryJpegLoad1 { public static void main(String[] args) { FileInputStream fis; JPEGImageDecoder decoder; BufferedImage bi = null; if(args.length < 1){ System.out.println("Usage: jpeg filename as argument"); return;} try{ // because of file open and read fis = new FileInputStream(args[0]); decoder = JPEGCodec.createJPEGDecoder(fis); bi = decoder.decodeAsBufferedImage(); } catch(Exception e) { System.out.println(e); } // How small is it? System.out.println(bi.getWidth() + " " + bi.getHeight()); } // main() } // class TryJpegLoad1