Ken, You have to know how the pixels are encoded into the file, i.e. the file format, plus if there are any headers, etc. Luckily, you don't (usually) have to write your own encoding functions... sun provides a JPEG encoder in the com.sun.image.codec.jpeg package (it comes with the JDK... look here to get info http://java.sun.com/products/jdk/1.2/docs/guide/2d/api-jpeg/overview-summary.html ), and I am sure someone has written a PNG encoder... look around on the net with a good search engine for java & PNG... The JAI (Java Advanced Imaging) API may also provide what you need ( I found it while looking around Sun for Java and PNG ), as well as possibly the Java2D API... you can find (exhaustive) references to these if you go to Sun and type PNG into their site search. HTH, -Nate