Lab
8
Get started now
MSOE 3 3 #000000 #FFFFFF #000000 #FFFFFF #FFFFFF #FFFFFF #000000 #FFFFFF #000000* The first line specifies that the file contains an `.msoe` image. * The second line specifies, in order, the width and height of the image. * Each remain line specifies the colors of the pixels for one row of the image. * Line 3 specifies pixel colors for the first row in the image. * Line 4 specifies pixel colors for the second row in the image. * Line `k` specifies pixel colors for the `k-2` row in the image. Your program should be able to load [this `.msoe` image](hamburger.msoe). ### Loading and Saving Images The program must support loading and saving `.jpg`, `.png`, `.tiff`, and `.msoe` image file formats. The load button will open a `FileChooser` dialog that will allow the user to select the file to be loaded (`showOpenDialog()`). The program will use the extension to determine the format of the file and load the image. If the file extension is not supported or the file contents does not match the file extension, the program will display an error message. Pressing the reload button will reload the most recently loaded image. The save button will open a `FileChooser` dialog box that will allow the user to select the destination folder and type in the filename and extension (`showSaveDialog()`). The program will then write the image to that file using the file format that matches the file extension. If an unsupported file extension is entered, the program will display an error message without attempting to save the image. You should write your own `ImageIO` class is responsible for loading and saving images. The class must have the following public **class** methods: * **`read(Path path)`** — Reads in the specified image file and returns a `javafx.scene.image.Image` object containing the image. * **`write(Image image, Path path)`** — Writes the specified image to the specified path. If the extension on the file passed to either of these methods is `.msoe` then the appropriate private class method below is called to do the actual work. * **`readMSOE(Path path)`** — Reads an image file in `.msoe` format. * **`writeMSOE(Image image, Path path)`** — Writes an image file in `.msoe` format. Both `read()` and `write()` must throw an `IllegalArgumentException` if the `path` passed in has a file extension that specifies an unsupported image format. You may use the [`ImageUtil`](ImageUtil.html) class [`ImageUtil.jar`](ImageUtil.jar) to read and write files in the `.jpg`, `.png`, and `.tiff` formats. You must implement your own code to read and write `.msoe` files. ### Grayscale This transformation converts the image into a grayscale image. If the image is already grayscale, the transformation has no affect. In this transformation, the RGB components of each pixel are replaced with a single value. The replacement value can be calculated as: *gray = 0.2126R + 0.7152G + 0.0722B* [more info](http://en.wikipedia.org/wiki/Grayscale).
1)
The label at the bottom center of the window is not required but is the
first enhancement suggested in the Just for Fun section.