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

This preview shows page 1 - 2 out of 6 pages.

import java.util.Scanner;public class RleProgram {public static void main(String[] args) {Scanner input = new Scanner(System.in); //input//Declare Variablesbyte[] imageData = null;String strInput;int choice = 1;//1. Display welcome messageSystem.out.println("Welcome to the RLE image encoder!");//2. Display color test with the messageSystem.out.println("\nDisplaying Spectrum Image:");ConsoleGfx.displayImage(ConsoleGfx.testRainbow);//3. Display the menu - Part a: while loop or if-else chainwhile (choice != 0) {System.out.println("\nRLE 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: ");//Let user to select menu optionchoice = input.nextInt();//Prompt for input//option 1: ConsoleGfx.loadFile(userInput) and you want to store thereturned byte[] into imageData arrayif (choice == 1){System.out.print("Enter name of file to load: ");strInput = input.next();imageData = ConsoleGfx.loadFile(strInput);}//option 2: Store ConsoleGfx.testImage into the imageData arrayelse if (choice == 2){System.out.println("Test image data loaded.");imageData = ConsoleGfx.testImage;}//option 3: Reading RLE Stringelse if (choice == 3){System.out.print("Enter an RLE string to be decoded: ");strInput = input.next();imageData = decodeRle(stringToRle(strInput));

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture