Question: / * Program Name: PROGRAM NAME HERE * Student Name: YOUR NAME HERE * Net ID: NETID HERE * Student ID: STUDENT ID HERE (

/* Program Name: PROGRAM NAME HERE
* Student Name: YOUR NAME HERE
* Net ID: NETID HERE
* Student ID: STUDENT ID HERE (000-12-3456)
* Program Description: BRIEF, 1-2 SENTENCE DESCRIPTION HERE */
#include
#include
#include
#include
using namespace std;
struct Pixel {
// TODO: Implement the Pixel struct
};
class Picture {
private:
size_t width;
size_t height;
uint maxIntensity;
vector pixels;
public:
Picture();
const Pixel &getPixel(const size_t row, const size_t column) const;
Pixel &getPixel(const size_t row, const size_t column);
void setPixel(const size_t row, const size_t column, const Pixel &pixel);
void invert();
void flipY();
void flipX();
// istream is a generic interface that works with cin and ifstream
//- readInput(cin); // ok
//- readInput(fin); // ok
bool readInput(istream &in);
// ostream is a generic interface that works with cout and ofstream
//- writeOutput(cout); // ok
//- writeOutput(fout); // ok
void writeOutput(ostream &out);
};
// TODO: Implement the Picture class
bool Picture::readInput(istream &in){
//- Call `getline` once to check `"p3"`
//- Create a stringstream: `stringstream in_without_comments;`
//- Do while `getline` to get all the lines out of your input and
// check if the lines start with `'#'` then you can do
//`in_without_comments << line <<'
`
// for all the lines that are not comments
//- Then all that's in your `in_without_comments` is the numbers
//- Then after that you can simply use the extraction operator on the
//`stringstream`,`in_without_comments`, to read in all the numbers
//- Read out the `width`,`height`, and `maxIntensity`
//- Create a `vector` and use `width` and `height` to resize your vector
//- Use a for loop to read in all the pixels

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!