export planes as 16 bits PGM, second try

This commit is contained in:
tth
2022-03-02 00:59:36 +01:00
parent c17132e969
commit b98c398c3c
4 changed files with 16 additions and 4 deletions

0
lib/README.md Normal file
View File

View File

@@ -232,7 +232,7 @@ if (NULL==(fp=fopen(fname, "w"))) {
return -2;
}
fprintf(fp, "P2\n%d\n%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;
maxval = fimg_get_plane_maxvalue(psrc, plane);
fk = maxval / 65535.0;
@@ -250,7 +250,7 @@ for (idx=0; idx<area; idx++) {
fclose(fp);
return -1;
return 0;
}
/* ---------------------------------------------------------------- */
/* nouveau 10 fevrier 2022 */

12
lib/t.c
View File

@@ -28,8 +28,20 @@ if (foo) {
return -6;
}
foo = fimg_save_plane_as_pgm(&image, "red.pgm", 'r');
if (foo) {
fprintf(stderr, "err save red %d\n", foo);
return -6;
}
foo = fimg_save_plane_as_pgm(&image, "green.pgm", 'g');
if (foo) {
fprintf(stderr, "err save green %d\n", foo);
return -6;
}
foo = fimg_save_plane_as_pgm(&image, "blue.pgm", 'b');
if (foo) {
fprintf(stderr, "err save blue %d\n", foo);
return -6;
}
return 0;
}