Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Structure Of The Relational Database Model

Authors: Jan Paredaens ,Paul De Bra ,Marc Gyssens ,Dirk Van Gucht

1st Edition

3642699588, 978-3642699580

More Books

Students also viewed these Databases questions

Question

=+ Is secondary industrial action common and/or legal?

Answered: 1 week ago

Question

=+What sanctions are available to employers

Answered: 1 week ago

Question

=+ If strikes occur, are they legally regulated?

Answered: 1 week ago