#include #include #include int w, h; uint32_t *p; int err_scanf(void) { if (ferror(stdin)) perror(NULL); else fprintf(stderr, "expected an PAM on stdin with DEPTH 4 MAXVAL 255 TUPLTYPE RGB_ALPHA"); return 1; } int err_fread(void) { if (ferror(stdin)) perror(NULL); else if (feof(stdin)) fprintf(stderr, "input is too short\n"); else fprintf(stderr, "unexpected error from fread\n"); return 1; } int err_too_long(void) { fprintf(stderr, "input is too long\n"); return 1; } int count[0x1000000]; void count_pixel_values(void) { uint32_t *i = p; for (int y=0; y