Lab 2: Image Transformer
Overview
In this assignment, you will provide a simple Graphical User Interface that allows image files to be transformed using several specified transformations.
Commit 1 - JavaFX Application
Due prior to the start of class Tuesday Week 2
As part of the pre-lab activity you must ensure that you have JavaFX installed on your laptop.
In addition, you must rename the package to your MSOE username and create
the ImageCopy
class. The ImageCopy
class must extend the Application
class
and include your start()
method that will create the GUI. For this commit it,
at a minimum, must show a blank window.
Commit 2 - JavaFX Window
Due at the end of class Wednesday Week 2
Modify ImageCopy
so that it provides a user interface that matches the
screenshot below.

For this commit, you must add an action listener for the Copy button, the the button doesn't need to do anything for this commit.
Commit 3 - ImageIO class integration
Due at the end of class Wednesday Week 2
Replacing mocked
Package
Copy your ImageIO
class implementation from your lab 1 project into
this project and incorporate feedback from your instructor (if available).
Instead of using the classes/interfaces provided by the mocked
package,
you will use several JavaFX classes/interfaces:
Image
— Represents graphical images.WritableImage
— Represents a custom graphical image that is constructed from pixels supplied by the application.PixelReader
— Defines methods for retrieving pixel data from anImage
.PixelWriter
— Defines methods for writing the pixel data of aWritableImage
.
To use these, replace the imports in ImageIO
that used mocked
with javafx.scene.image
.
Add functionality so that when the user enters an input image filename in the first text field, an output image filename in the second text field, and then presses the Copy button, the program will read the specified image file and write it to the specified output file.
Commit 4 - Lab completed
Due 11pm Monday of Week 2
Support for .png
Image Files
You must provide support for reading and writing images in the .png
format. You must
create two private class methods:
readPNG(Path path)
— Reads in the specified image file in.png
format and returns anImage
object containing the image.writePNG(Path path, Image image)
— Writes the specified image to the specified path using the.png
file format.
An Image
class constructor supports reading PNG images. Writing PNG images
is a bit more involved. It can be done using the javax.imageio.ImageIO.write()
method, and you can use the javafx.embed.swing.SwingFXUtils.fromFXImage()
method to get a BufferedImage
(that is a RenderedImage
).
Update the public read()
and write()
methods to call the readPNG()
and writePNG()
methods when appropriate.
Exception Handling
If any problems are encountered with reading the input files or writing the output file, the program should display a useful error message to the console and continue running. The program should not crash or display any exceptions.
Just For Fun
Ambitious students may wish to:
- Display all of the input and/or output image.
You can display an Image
in the Scene
by placing the Image
in a ImageView
.
Acknowledgement
This laboratory assignment, developed by Dr. Chris Taylor.