RleProgram.java - import java.util public class RleProgram...

This preview shows page 1 - 3 out of 7 pages.

import java.util.*; public class RleProgram { public static String strInput; public static byte[] fileData = null; public static Scanner scan = new Scanner(System.in); public static void printMenu() { System.out.println("RLE Menu"); System.out.println("--------"); System.out.println("0. Exit"); System.out.println("1. Load File"); System.out.println("2. Load Test Image"); System.out.println("3. Read RLE String"); System.out.println("4. Read RLE Hex String"); System.out.println("5. Read Data Hex String"); System.out.println("6. Display Image"); System.out.println("7. Display RLE String"); System.out.println("8. Display Hex RLE Data"); System.out.println("9. Display Hex Flat Data"); System.out.println(); System.out.print("Select a Menu Option:"); } public static void Menu(int menuInput) { switch(menuInput) { case 0: { break; } case 1: { System.out.print("Enter name of file to load: "); strInput = scan.next(); fileData = ConsoleGfx.loadFile(strInput); if (fileData.length == 0) System.out.println("This file doesn't exist."); break; } case 2: { fileData = ConsoleGfx.testImage; System.out.println("Test image data loaded."); break; } // Read RLE String such as 28:10:6B:10:10B:10:2B:10:12B:10:2B:10:5B:20:11B:10:6B:10 case 3: { System.out.print("Enter an RLE string to be decoded: "); strInput = scan.next(); fileData = decodeRle(stringToRle(strInput)); break; } //Read RLE Hex String such as 28106B10AB102B10CB102B105B20 case 4: { System.out.print("Enter the hex string holding RLE data: "); strInput = scan.next(); fileData = decodeRle(stringToData(strInput)); break; } //read flat data hex string such as 880bbbbbb0bbbbbbbbbb0b case 5: { System.out.print("Enter the hex string holding flat data: "); strInput = scan.next();
System.out.println(); fileData = stringToData(strInput); break; } case 6: { System.out.println("Displaying image..."); if (fileData == null || fileData.length == 0) System.out.println("(no data)");

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture