void saveImage(int w, int h, rgb_t **tex, char *filename, int fileType) { if (fileType == PNG) { saveAsPNG(w, h, tex, strcat(filename, ".png")); } else { saveAsPPM(w, h, tex, strcat(filename, ".ppm")); } }
int main(int argc, char **argv) { frame_t frame; bitmap_t *bitmap; bitmap_t *resampled; int width = DEFAULT_WIDTH, height = DEFAULT_HEIGHT; int s = 1; int opt; frame.x = 0; frame.y = 0; frame.magn = 1; while ((opt = getopt(argc, argv, "w:h:y:r:i:m:t:s:")) != -1) { switch (opt) { case 'w': sscanf(optarg, "%d", &width); break; case 'h': sscanf(optarg, "%d", &height); break; case 'r': sscanf(optarg, "%Lf", &frame.x); break; case 'i': sscanf(optarg, "%Lf", &frame.y); break; case 'm': sscanf(optarg, "%f", &frame.magn); break; case 't': sscanf(optarg, "%Lf", &frame.rotation); break; case 's': sscanf(optarg, "%d", &s); break; case '?': default: printUsage(); return 1; } } if (optind != argc - 1) { printUsage(); return 1; } bitmap = createBitmap(width * s, height * s); renderFrame(bitmap, &frame); if (s > 1) { printf("Resampling...\n"); resampled = createBitmap(width, height); resample(bitmap, resampled, s); bitmapGC(bitmap); printf("Done\n"); } else { resampled = bitmap; } saveAsPPM(resampled, argv[optind]); bitmapGC(resampled); return 0; }
void Image::saveAsPPM(std::string const& fileName) const { saveAsPPM(fileName, 0, 0, myWidth, myHeight); }