Question
Create a new project folder and save the two source images previously downloaded from any website. These image files are named day1.png and a second
Create a new project folder and save the two source images previously downloaded from any website. These image files are named day1.png and a second based on your username, with dimensions 450x300.
2. Create a new file called Lab05.java, which will be your program to decode the secret password.
3. In your main() method, create three Image objects: two that load and display the day1.png and your username.png images, and a third that will show the decoded password.
4. For the first two Image objects, use the Image constructor that specifies the name of the file to read and where to draw it in your Window. For example, the following constructor reads "day1.png" and draws it at x=0, y=0. Image day1 = new Image("day1.png", 0, 0);
5. For the third Image object, use the Image constructor that specifies the size and location of a new blank Image. For example, the following constructor creates a blank image at x=450, y=0 with width=450, height=300. Image password = new Image(450, 0, 450, 300);
6. After instantiating all three Image objects, write nested for-loops to inspect every pixel in the two source Images. One of your for-loops must generate pixel row indexes, and the other must generate column indexes. Because the images have dimensions 450x300, there are 450 columns and 300 rows of pixels in your images.
7. To read the blue component of a pixel in an Image at row r and column c, use the getBlue(...) Image object method. For example, the following statement gets the blue component of the pixel at row r and column c in the Image day1. Note that the column index is the first argument and the row index is the second argument. int blue1 = day1.getBlue(c, r); 8. To set a pixel color in an image, use the Image objects setPixel(...) method, which takes row and column of the pixel to set, plus the red, green and blue pixel color components. For example, the following method sets the color of the pixel at row r and column c to be black (i.e. red=0, green=0, blue=0). password.setPixel(c, r, 0, 0, 0);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started