#define _XOPEN_SOURCE #include "img.h" #include #include int main(int argc, char **argv) { if (argc != 4) { fprintf(stderr, "\nusage: %s count width height", argv[0]); exit(EXIT_FAILURE); } int width, height, c; c = atoi(argv[1]); width = atoi(argv[2]); height = atoi(argv[3]); pix_row rows[width]; pix p; char filename[60]; int i, j, x, y, count; image img; p.r = 200; p.g = 200; p.b = 200; srand48(1000); for (count = 0; count < (c); count++) { for (i = 0; i < width; i++) { rows[i].p = malloc(height * sizeof(pix)); for (j = 0; j < height; j++) { p.r = (int) (drand48() * 255); p.g = (int) (drand48() * 255); p.b = (int) (drand48() * 255); rows[i].p[j] = p; } } sprintf(filename, "images/image%05d.png", count); img = initialize_png("image010", filename, width, height); write_image(&img, rows); finish_image(&img); for (i = 0; i < width; i++) { free(rows[i].p); } } return (0); }