import java.io.*; public class RawDataConverter { public static final int RAW_COLS = 164; public static final int RAW_ROWS = 124; public static final int COLS = 160; public static final int ROWS = 120; public static final int HEADER_SIZE = 54; public static final int RED = 0; public static final int GREEN = 1; public static final int BLUE = 2; private RandomAccessFile in, out; private byte[][][] data; public RawDataConverter(String infile, String outfile){ try { in = new RandomAccessFile(infile, "r"); out = new RandomAccessFile(outfile, "rw"); } catch(Exception e){ System.out.println("Error opening/creating files"); System.exit(0); return; } data = new byte[RAW_ROWS][RAW_COLS][3]; } private void writeInt(int temp) throws IOException { out.writeByte(temp); out.writeByte(temp >> 8); out.writeByte(temp >> 16); out.writeByte(temp >> 24); } private void writeWord(int temp) throws IOException { out.writeByte(temp); out.writeByte(temp >> 8); } private void writeByte(int temp) throws IOException { out.writeByte(temp); } private byte b2b(byte[] num){ if(num[1] > 40) num[1] -= 31; else num[1] -= 30; if(num[0] > 40) num[0] -= 31; else num[0] -= 30; return (byte) (((num[0] << 4) & 0xf0) |(num[1] & 0x0f)); } private void readArray() throws IOException { int col=0, row=0; byte[] num = new byte[2]; for(int i=0; i 0; row--){ for(col=1; col <= COLS; col++){ if(data[row][col][BLUE] != 0){ out.writeByte(data[row][col][BLUE]); out.writeByte(data[row][col][GREEN]); out.writeByte(data[row][col][RED]); } else if(data[row][col][RED] != 0){ out.writeByte(data[row][col][BLUE]); out.writeByte(data[row][col][GREEN]); out.writeByte(data[row][col][RED]); } else { out.writeByte(data[row][col][BLUE]); out.writeByte(data[row][col][GREEN]); out.writeByte(data[row][col][RED]); } } } } catch(Exception e){ System.out.println("Error converting"); e.printStackTrace(); System.out.println("row = " + row + " col = " + col); } try { out.close(); } catch(Exception e){} } public static void main(String[] args){ if(args.length != 2){ System.out.println("Expected Usage: java RawDataConverter "); System.exit(0); } new RawDataConverter(args[0], args[1]).convert(); } }