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

View File

@ -4,7 +4,7 @@
* http://la.buvette.org/photos/cumul * http://la.buvette.org/photos/cumul
*/ */
#define FIMG_VERSION 170 #define FIMG_VERSION 171
/* /*
* in memory descriptor * in memory descriptor
@ -22,7 +22,7 @@ typedef struct {
} FloatImg; } FloatImg;
/* /*
* fimg file header * fimg file header (short version)
*/ */
typedef struct { typedef struct {
char magic[8]; char magic[8];

0
lib/README.md Normal file
View File

View File

@ -232,7 +232,7 @@ if (NULL==(fp=fopen(fname, "w"))) {
return -2; 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; 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;
@ -250,7 +250,7 @@ for (idx=0; idx<area; idx++) {
fclose(fp); fclose(fp);
return -1; return 0;
} }
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
/* nouveau 10 fevrier 2022 */ /* nouveau 10 fevrier 2022 */

12
lib/t.c
View File

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