FloatImg/funcs/fimg-libpnm.c

54 lines
1.2 KiB
C
Raw Normal View History

2019-09-13 04:48:12 +11:00
/*
* interface FloatImg <-> libpnm(3)
*/
#include <stdio.h>
#include <stdlib.h>
2021-05-20 18:31:28 +11:00
#include <stdint.h>
2019-09-13 04:48:12 +11:00
#include <string.h>
#include <pam.h>
#include "../floatimg.h"
extern int verbosity;
/* --------------------------------------------------------------------- */
2022-07-06 19:27:55 +11:00
static void print_struct_pam(struct pam *ppam, char *text)
2019-09-13 04:48:12 +11:00
{
2024-05-02 06:38:19 +11:00
printf("\ttext %s\n", text);
printf("\tsize %d\n", ppam->size);
printf("\tformat %d 0x%04x\n", ppam->format, ppam->format);
printf("\tplainformat %d\n", ppam->plainformat);
printf("\twidth & height %d %d\n", ppam->width, ppam->height);
printf("\tdepth %d\n", ppam->depth);
printf("\tmaxval %lu\n", ppam->maxval);
2019-09-13 04:48:12 +11:00
}
/* --------------------------------------------------------------------- */
int fimg_pnm_infos(char *fname)
{
struct pam inpam;
FILE *fp;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, fname);
#endif
2024-05-02 06:38:19 +11:00
printf(" --- infos for '%s' ------------\n", fname);
2019-09-13 04:48:12 +11:00
if (NULL==(fp=fopen(fname, "r"))) {
perror(fname);
exit(1);
}
pnm_readpaminit(fp, &inpam, sizeof(inpam));
print_struct_pam(&inpam, fname);
fclose(fp);
return 0;
}
/* --------------------------------------------------------------------- */