2019-03-03 16:22:55 +01:00
|
|
|
/*
|
|
|
|
* PNG ---> FIMG
|
2020-11-09 20:27:57 +01:00
|
|
|
*
|
|
|
|
* Attention : certains fichiers PNG ne passent pas cette
|
|
|
|
* moulinette, mais le bug est dans la bibliotheque de
|
|
|
|
* fonctions 'libpnglite'. Une solution de remplacement
|
|
|
|
* devrait etre a l'etude un de ces jours...
|
2019-03-03 16:22:55 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2021-05-20 09:31:28 +02:00
|
|
|
#include <stdint.h>
|
2019-03-03 16:22:55 +01:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "../floatimg.h"
|
|
|
|
|
2019-06-29 23:50:03 +02:00
|
|
|
int verbosity = 0;
|
|
|
|
|
2021-02-22 14:22:41 +01:00
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
void help(int k)
|
|
|
|
{
|
|
|
|
if (verbosity) fimg_print_version(k);
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
}
|
2019-03-03 16:22:55 +01:00
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
FloatImg fimg;
|
2021-02-22 14:22:41 +01:00
|
|
|
int foo, opt;
|
2019-03-03 16:22:55 +01:00
|
|
|
|
2021-02-22 14:22:41 +01:00
|
|
|
while ((opt = getopt(argc, argv, "hv")) != -1) {
|
|
|
|
switch(opt) {
|
|
|
|
case 'v': verbosity++; break;
|
|
|
|
case 'h': help(1); exit(1);
|
2023-05-29 09:06:57 +02:00
|
|
|
default: exit(1);
|
2021-02-22 14:22:41 +01:00
|
|
|
}
|
|
|
|
}
|
2020-11-09 20:27:57 +01:00
|
|
|
|
2021-02-22 14:22:41 +01:00
|
|
|
if (2 != argc-optind) {
|
|
|
|
fprintf(stderr, "error: %s need two filenames\n", argv[0]);
|
2019-03-03 16:22:55 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&fimg, 0, sizeof(FloatImg));
|
|
|
|
|
2021-02-22 14:22:41 +01:00
|
|
|
foo = fimg_create_from_png(argv[optind], &fimg);
|
2019-03-03 16:22:55 +01:00
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "%s : err %d, abort.\n", argv[0], foo);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2021-02-22 14:22:41 +01:00
|
|
|
if (verbosity) fimg_describe(&fimg, argv[optind+1]);
|
2019-03-03 16:22:55 +01:00
|
|
|
|
2021-02-22 14:22:41 +01:00
|
|
|
foo = fimg_dump_to_file(&fimg, argv[optind+1], 0);
|
2020-11-13 01:00:20 +01:00
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "save as '%s' -> err %d\n", argv[2], foo);
|
|
|
|
exit(1);
|
|
|
|
}
|
2019-03-03 16:22:55 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|