Outprintn break case 2 image data loaded decodeddata

This preview shows page 1 - 4 out of 5 pages.

System.out.print("\n"); break; case 2 : System.out.println("Test image data loaded."); decodedData = ConsoleGfx.testImage; dataExists = true; System.out.print("\n"); break; case 3: System.out.print("Enter an RLE string to be decoded: "); String dataToDecode = askForInput.next(); encodedData = stringToRle(dataToDecode);
decodedData = decodeRle(encodedData); dataExists = true; break; case 4: System.out.print("Enter the hex string holding RLE data: "); String hexStringToDecode = askForInput.next(); decodedData = stringToData(hexStringToDecode); dataExists = true; break; case 5: System.out.print("Enter the hex string holding flat data: "); String stringToDecode = askForInput.next(); decodedData = stringToData(stringToDecode); encodedData = encodeRle(decodedData); dataExists = true; break; case 6 : System.out.println("Displaying image:"); ConsoleGfx.displayImage(decodedData); System.out.print("\n"); break; case 7: if (!dataExists) { System.out.println("(no data)"); break; } encodedData = encodeRle(decodedData); represented = toRleString(encodedData); System.out.println("RLE representation: " + represented); break; case 8: if (!dataExists) { System.out.println("(no data)"); break; } encodedData = encodeRle(decodedData); represented = toHexString(encodedData); System.out.println("RLE hex values: " + represented); break; case 9: if (!dataExists) { System.out.println("(no data)"); break; } flatData = toHexString(decodedData); System.out.println("Flat hex values: " + flatData); break; default: System.out.println("Error! Invalid input."); break; } } } // methods for the different cases public static String toHexString(byte[] data) { String outputData = "";
for (int i = 0; i < data.length; i++) { outputData = outputData + String.format("%01x", (data[i])); } return outputData; } public static int countRuns(byte[] flatData) { int count = 1; for (int i =0; i < flatData.length - 1; i++) {

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture