#include #include #include #include using namespace std; const int XDIM{1000}; const int YDIM{400}; using ColorT = unsigned char; struct PixelT { ColorT color[3]; }; using ImageT = vector >; void WriteImage(string baseFileName, const ImageT & image); int main() { vector> image(XDIM,vector(YDIM)); // write a loop that will fill in the array with colors. WriteImage("foo", image); return 0; } void WriteImage(string baseFileName, const ImageT & image){ // open a file for writing // write the PBM header // the magic number P6 (in ascii) followed by a newline // width space height newline in ascii // the maximum value (255) newline in ascii // write the rgb values row by row in binary format // close the file // run ppmtogif or ppmtojpeg string cmd { "ppmtogif < " + pngName + " > " + gifName}; system(cmd.c_str()); unlink(pngName.c_str()); }