/** Writes a RealGrayImage to a file, byteSizing first */ public void writeByteSized(RealGrayImage im) throws IOException { X = im.X(); Y = im.Y(); // convert to byte size RealGrayImage tmpim = (RealGrayImage) im.copy(); tmpim.byteSize(); // write PGM in raw format writeRawPRGMHeader(X, Y); for (int y = 0; y < Y; y++) { for (int x = 0; x < X; x++) { data.write((byte) tmpim.get(x, y)); } } }