Question: Create a Picture class that contains: 1 . a private vector of Pixel structures. 2 . a private integer representing the width of the picture.

Create a Picture class that contains:
1. a private vector of Pixel structures.
2. a private integer representing the width of the picture.
3. a private integer representing the height of the picture.
4. a private integer representing the maximum intensity of each pixel color.
5. a public constructor that takes no arguments. This constructor will set the width, height, and maximum intensity to 0.
6. a public accessor called get_pixel. This function will take a row and a column as integer values, and it will return the given Pixel at the row and column by-constant-reference. You may assume that the row and column will exist. Remember, the private vector stores all pixel values in one dimension. This means that you'll need a little bit of math to figure out where the pixel begins. For this, remember that each row contains a number of pixels, which is equal to the number of columns. For example, a file that has a width of 10 and a height of 5 has 10 columns and 5 rows. This means that row[0] starts at vector.at(0) and row[1] starts at vector.at(total_number_of_columns) and row[2] starts at vector.at(total_number_of_columns *2);
7. a public mutator also called get_pixel. This function is exactly like the accessor get_pixel, except it is a mutator, and allows for you to write set_pixel by returning a mutable reference to a pixel.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!