#include #include #include void write_pgm(int* pixels, int horPixels, int vertPixels, std::string filename) { if(horPixels == 0 || vertPixels == 0) { std::cerr << "Leeres Pixel Array" << std::endl; return; } // write file // unfortunately we cannot use C++-11 which would simplify our life in that case std::ofstream outfile; outfile.open(filename.c_str()); outfile << "P2" << std::endl << horPixels << " " << vertPixels << std::endl; // renormalize if necessary int maxVal = 0; for(int entry=0; entry 65535) { outfile << 65535 << std::endl; for(int j=0, entry=0; j