2019-12-14 04:18:07 +11:00
|
|
|
/*
|
|
|
|
* converting a floatimg to a PNG
|
|
|
|
*/
|
|
|
|
|
2019-03-04 02:22:55 +11:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "../floatimg.h"
|
|
|
|
|
2019-12-14 04:18:07 +11:00
|
|
|
int verbosity;
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
|
|
int convertir_fimg_en_PNG(char *srcname, char *dstname, int notused)
|
|
|
|
{
|
|
|
|
int foo, infos[3];
|
|
|
|
FloatImg fimg;
|
|
|
|
|
|
|
|
#if DEBUG_LEVEL
|
|
|
|
fprintf(stderr, ">>> %25s ( '%s' '%s' %d )\n", __func__,
|
|
|
|
srcname, dstname, notused);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
foo = fimg_fileinfos(srcname, infos);
|
|
|
|
if (foo) { fprintf(stderr, "'%s' get dims -> %d\n", srcname, foo); }
|
|
|
|
|
|
|
|
if (verbosity) {
|
|
|
|
fprintf(stderr, "image '%s' is %d x %d %s\n",
|
|
|
|
srcname, infos[0], infos[1],
|
|
|
|
fimg_str_type(infos[2]));
|
|
|
|
}
|
|
|
|
|
|
|
|
foo = fimg_create_from_dump(srcname, &fimg);
|
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "create fimg from '%s' -> %d\n", srcname, foo);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
foo = fimg_save_as_png(&fimg, dstname, 0);
|
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "saving as png '%s' -> %d\n", dstname, foo);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
fimg_destroy(&fimg);
|
|
|
|
|
2019-12-15 01:19:35 +11:00
|
|
|
return 0;
|
2019-12-14 04:18:07 +11:00
|
|
|
}
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
|
|
|
2019-03-04 02:22:55 +11:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2019-12-14 04:18:07 +11:00
|
|
|
int foo;
|
2019-03-04 02:22:55 +11:00
|
|
|
|
|
|
|
if (3 != argc) {
|
|
|
|
fimg_print_version(1);
|
|
|
|
fprintf(stderr, "usage:\n\t%s foo.fimg bar.pnm\n", argv[0]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2019-12-14 04:18:07 +11:00
|
|
|
foo = convertir_fimg_en_PNG(argv[1], argv[2], 0);
|
|
|
|
fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo);
|
2019-08-12 10:53:17 +11:00
|
|
|
|
2019-03-04 02:22:55 +11:00
|
|
|
return 0;
|
|
|
|
}
|
2019-12-14 04:18:07 +11:00
|
|
|
/* ----------------------------------------------------------------- */
|
2019-03-04 02:22:55 +11:00
|
|
|
|