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
Program Description: BRIEF, SENTENCE DESCRIPTION HERE
#include
#include
#include
#include
using namespace std;
struct Pixel
TODO: Implement the Pixel struct
;
class Picture
private:
sizet width;
sizet height;
uint maxIntensity;
vector pixels;
public:
Picture;
const Pixel &getPixelconst sizet row, const sizet column const;
Pixel &getPixelconst sizet row, const sizet column;
void setPixelconst sizet row, const sizet column, const Pixel &pixel;
void invert;
void flipY;
void flipX;
istream is a generic interface that works with cin and ifstream
readInputcin; ok
readInputfin; ok
bool readInputistream ∈
ostream is a generic interface that works with cout and ofstream
writeOutputcout; ok
writeOutputfout; ok
void writeOutputostream &out;
;
TODO: Implement the Picture class
bool Picture::readInputistream &in
Call getline once to check p
Create a stringstream: stringstream inwithoutcomments;
Do while getline to get all the lines out of your input and
check if the lines start with # then you can do
inwithoutcomments line
for all the lines that are not comments
Then all that's in your inwithoutcomments is the numbers
Then after that you can simply use the extraction operator on the
stringstreaminwithoutcomments to read in all the numbers
Read out the widthheight 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
