fine tuning

This commit is contained in:
tth 2022-03-06 04:47:58 +01:00
parent b98c398c3c
commit 0cdb977a82

View File

@ -227,17 +227,30 @@ switch (plane) {
abort(); break; abort(); break;
} }
if (NULL == ptrplane) { /* mmmm... */
fprintf(stderr, "%s: mmmm...\n", __func__);
return -3;
}
if (NULL==(fp=fopen(fname, "w"))) { if (NULL==(fp=fopen(fname, "w"))) {
perror(fname); perror(fname);
return -2; 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); fprintf(fp, "P2\n%d %d\n65535\n\n", psrc->width, psrc->height);
area = psrc->width * psrc->height; area = psrc->width * psrc->height;
maxval = fimg_get_plane_maxvalue(psrc, plane); maxval = fimg_get_plane_maxvalue(psrc, plane);
fk = maxval / 65535.0; 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; printed = 0;
for (idx=0; idx<area; idx++) { for (idx=0; idx<area; idx++) {
@ -265,6 +278,10 @@ float accu;
fprintf(stderr, ">>> %s ( %p %s %d )\n", __func__, src, fname, flags); fprintf(stderr, ">>> %s ( %p %s %d )\n", __func__, src, fname, flags);
#endif #endif
if (flags) {
fprintf(stderr, "%s: flags must be 0\n", __func__);
}
if ( src->type != FIMG_TYPE_RGB ) { if ( src->type != FIMG_TYPE_RGB ) {
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s : type %d is bad.\n", __func__, src->type); fprintf(stderr, "%s : type %d is bad.\n", __func__, src->type);
@ -277,7 +294,11 @@ if (NULL==(fp=fopen(fname, "w"))) {
return -2; 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; area = src->width * src->height;
maximum = fimg_get_maxvalue(src); maximum = fimg_get_maxvalue(src);