Question: #include #include #include #include using namespace std; const int SIZE = 150; class color { protected: int a[SIZE][SIZE*3]; int m; int n; public: color(); color(unsigned

#include #include #include #include using namespace std; const int SIZE = 150;

class color { protected: int a[SIZE][SIZE*3]; int m; int n;

public: color(); color(unsigned char, unsigned char, unsigned char); unsigned char r; unsigned char g; unsigned char b; static const int Width = 240; static const int height = 320; int getM()const; void setM(int m); int getN()const; void setN(int n); void writeppm(string); void createpicture();

}; int color::getM()const{ return m; } void color::setM(int M){ this->m=m; } int color::getN()const{ return n; } void color::setN(int n){ this->n=n; } color::color(){ r = 0; g = 0; b = 0; } color::color(unsigned char, unsigned char, unsigned char){ r = 0; g = 0; b = 0; } void color::writeppm(string filename){ ofstream File(filename.c_str()); int amount = 255; File << "P3" << endl; File << "Created by " << endl; File << Width << " " << height << endl; File << amount << endl; File << " " << endl; for (int i = 0; i < m; i++) { for (int j = 0; j < n*3; j++) File << a[i][j]<< endl; File << endl; } File << endl;

} void color::createpicture(){ color grey(127,127,127);

for(int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { a[i][j*3]=grey.r; a[i][j*3+1]=grey.g; a[i][j*3+2]=grey.b; } } }

int main() { color X; X.createpicture(); X.writeppm("image1.ppm"); cout << "Image has been created!!" << endl; return 0; }

I am not gettint the image -getting the pm, width height - but no image no cout image has been created - what I'm I doing wrong? thanks C++

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 Databases Questions!