Answered step by step
Verified Expert Solution
Link Copied!

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 7 B: Art Program! For our last assignment in CSE 1321L, 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 ASCII/text 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 1322).
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 in-between each value. Returns nothing.
In a separate Assignment7B driver class, do the following:
Prompt the user to enter a width and height value
You will create a 2D list of Pixel object based on the width and height. Dont be
scared! This is similar to creating a 2D list of strings.
Prompt the user for the initial fill color this will be used to initialize all the Pixel
objects in the 2D 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:
P3
255
The width and height values should be what the user entered, and the pixel
values should come from the 2D 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: 3
Enter an image height: 4
Enter the fill colors red value: 21
Enter the fill colors green value: 25
Enter the fill colors blue value: 200
What will you do?
1) Fill in a pixel
2) Fill in a line
3) Print the image
4) Quit
Choice? 3
P3
34
255
212520021252002125200
212520021252002125200
212520021252002125200
212520021252002125200
What will you do?
1) Fill in a pixel
2) Fill in a line
3) Print the image
4) Quit
Choice? 1
Row: 2
Column: 1
New Red Color: 123
New Green Color: 98
New Blue Color: 5
What will you do?
1) Fill in a pixel
2) Fill in a line
3) Print the image
4) Quit
Choice? 2
Row: 0
Column: 0
Length: 3
New Red Color: 6
New Green Color: 78
New Blue Color: 15
What will you do?
1) Fill in a pixel
2) Fill in a line
3) Print the image
4) Quit
Choice? 4
P3
34
255
678156781567815
212520021252002125200
21252001239852125200
212520021252002125200
Closing...
python please

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

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions