diff --git a/lib/fimg-pnm.c b/lib/fimg-pnm.c index 2d248e6..716623d 100644 --- a/lib/fimg-pnm.c +++ b/lib/fimg-pnm.c @@ -227,17 +227,30 @@ switch (plane) { abort(); break; } +if (NULL == ptrplane) { /* mmmm... */ + fprintf(stderr, "%s: mmmm...\n", __func__); + return -3; + } + if (NULL==(fp=fopen(fname, "w"))) { perror(fname); return -2; } +/* WARNING ! + * some software (yes, povray, I look at you) doesn't like + * width and height on two separate lines. + */ fprintf(fp, "P2\n%d %d\n65535\n\n", psrc->width, psrc->height); + area = psrc->width * psrc->height; maxval = fimg_get_plane_maxvalue(psrc, plane); fk = maxval / 65535.0; -fprintf(stderr, "%s: maxval of %c = %f\n", __func__, plane, maxval); +if (verbosity) { + fprintf(stderr, "%s: maxval of plane '%c' = %f\n", __func__, + plane, maxval); + } printed = 0; for (idx=0; idx>> %s ( %p %s %d )\n", __func__, src, fname, flags); #endif +if (flags) { + fprintf(stderr, "%s: flags must be 0\n", __func__); + } + if ( src->type != FIMG_TYPE_RGB ) { #if DEBUG_LEVEL fprintf(stderr, "%s : type %d is bad.\n", __func__, src->type); @@ -277,7 +294,11 @@ if (NULL==(fp=fopen(fname, "w"))) { return -2; } -fprintf(fp, "P2\n%d\n%d\n65532\n\n", src->width, src->height); +/* WARNING ! + * some software (yes, povray, I look at you) doesn't like + * width and height on two separate lines. + */ +fprintf(fp, "P2\n%d %d\n65532\n\n", src->width, src->height); area = src->width * src->height; maximum = fimg_get_maxvalue(src);