// This program copies pixel data from a file to the screeen. // It reads 256 by 256 bytes from file pic.data and makes each into a gray pixel. // C code in mpd.c makes such a file as a test. import java.awt.*; import java.awt.image.*; import java.io.*; class Main { static BufferedImage I; static int rgb(FileInputStream is)throws IOException {int r=is.read(), g=is.read(), b=is.read(); return r<<16|g<<8|b;} static int shrt(FileInputStream is)throws IOException {int r=is.read(), g=is.read(); return r<<8|g;} static public void main( String[] args ) throws FileNotFoundException, IOException { FileInputStream is = new FileInputStream("pic.data"); final int X = shrt(is), Y = shrt(is); I = new BufferedImage(X, Y, BufferedImage.TYPE_INT_RGB); Frame f = new Frame( "paint Example" ); f.add("Center", new MainCanvas()); f.setSize(new Dimension(X,Y+22)); for (int i = 0; i