Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assignment 7 B: Art Program! For our last assignment in CSE 1 3 2 1 L , we ll learn how to create a basic
Assignment B: Art Program! For our last assignment in CSE L well learn how to
create a basic image editing program. Most images are saved in binary format this
means they are not human readable without special software like a hex editor.
However, a few are saved in ASCIItext mode, and you can read and edit them with just
a text editor. One such type is the black and white PBM images you created in a
previous assignment. For this one, well create the color Portable Pix Map image format.
You will create a program that generates the contents of a PPM file for a square image
well learn how to actually save a file in CSE
You will create a Pixel class which has three attributes:
red: int
green: int
blue: int
You will create a constructor that takes user input to assign the three RGB values. The
class will also have the following functions:
changeRGB : Takes in three integers to update the red, green, and blue
attributes. Returns nothing.
printRGB : Takes in nothing. Prints the red, green, and blue attributes in order
with a single space inbetween each value. Returns nothing.
In a separate AssignmentB driver class, do the following:
Prompt the user to enter a width and height value
You will create a D list of Pixel object based on the width and height. Dont be
scared! This is similar to creating a D list of strings.
Prompt the user for the initial fill color this will be used to initialize all the Pixel
objects in the D list to the same RGB
Repeatedly prompt the user to make one of the following choices:
Print the PPM file to the screen. Note that every valid PPM file starts with a
header which looks like this:
P
The width and height values should be what the user entered, and the pixel
values should come from the D lists objects.
Change a pixel to a new color. Prompt the user for the pixels coordinates and
the new RGB value, then update the Pixel object at that location in the list.
Refer to your prior work with the level map creator the logic is similar.
Change a line of pixels to a new color. Prompt the user for the starting
coordinates, the length, and the new RGB value. Then, update the colors of
all Pixel objects in that horizontal line. Refer to your prior work with the level
map creator the logic is similar.
Quit. Print the final image to the screen and stop the program.
If youre interested in actually seeing the image itself, check the appendix of this
assignment.
Sample Output:
Portable Pix Map Art Program
Enter an image width:
Enter an image height:
Enter the fill colors red value:
Enter the fill colors green value:
Enter the fill colors blue value:
What will you do
Fill in a pixel
Fill in a line
Print the image
Quit
Choice?
P
What will you do
Fill in a pixel
Fill in a line
Print the image
Quit
Choice?
Row:
Column:
New Red Color:
New Green Color:
New Blue Color:
What will you do
Fill in a pixel
Fill in a line
Print the image
Quit
Choice?
Row:
Column:
Length:
New Red Color:
New Green Color:
New Blue Color:
What will you do
Fill in a pixel
Fill in a line
Print the image
Quit
Choice?
P
Closing...
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