Compare commits
No commits in common. "119ab151bbf13926c62a4b5203ebc60687186dab" and "2aabc8b26bb8bbb59c1d1c85dd3a01c36ea47e3c" have entirely different histories.
119ab151bb
...
2aabc8b26b
@ -41,7 +41,6 @@ int fimg_destroy(FloatImg *fimg);
|
||||
int fimg_print_version(int k);
|
||||
void fimg_printhead(FloatImg *h);
|
||||
int fimg_describe(FloatImg *head, char *txt);
|
||||
char *fimg_str_type(int type);
|
||||
int fimg_fileinfo(char *fname, int *datas);
|
||||
int fimg_plot_rgb (FloatImg *head, int x, int y, float r, float g, float b);
|
||||
int fimg_clear(FloatImg *fimg);
|
||||
|
@ -2,7 +2,7 @@
|
||||
# building the base library
|
||||
#
|
||||
|
||||
COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=0
|
||||
COPT = -Wall -fpic -g -pg -no-pie -DDEBUG_LEVEL=0
|
||||
OBJS = fimg-core.o fimg-pnm.o fimg-file.o fimg-math.o \
|
||||
fimg-timers.o operators.o fimg-2gray.o \
|
||||
interpolate.o fimg-compare.o
|
||||
|
@ -24,7 +24,7 @@ switch (type) {
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
char *fimg_str_type(int type)
|
||||
static char *fimg_str_type(int type)
|
||||
{
|
||||
switch (type) {
|
||||
case FIMG_TYPE_GRAY: return "gray";
|
||||
|
@ -26,8 +26,8 @@ fimg2pnm: fimg2pnm.c $(DEPS)
|
||||
fimg2png: fimg2png.c $(DEPS)
|
||||
gcc $(COPT) $< ../libfloatimg.a -o $@
|
||||
|
||||
addtga2fimg: addtga2fimg.c $(DEPS)
|
||||
gcc $(COPT) $< ../libfloatimg.a -limageSO -lm -o $@
|
||||
# addtga2fimg: addtga2fimg.c $(DEPS)
|
||||
# gcc $(COPT) $< ../libfloatimg.a -limageSO -lm -o $@
|
||||
|
||||
addpnm2fimg: addpnm2fimg.c $(DEPS)
|
||||
gcc $(COPT) $< ../libfloatimg.a -lm -o $@
|
||||
|
@ -67,8 +67,8 @@ if (foo) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( 0==access(argv[2], R_OK) ) { /* fimg is readable */
|
||||
fprintf(stderr, "%s is ok.\n", argv[2]);
|
||||
if ( 0==access(argv[2], R_OK|W_OK) ) { /* fimg is readable */
|
||||
// fprintf(stderr, "%s exist\n", argv[2]);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "*** must create '%s' %dx%d first !!!\n",
|
||||
|
@ -11,23 +11,21 @@
|
||||
int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
int convertir_fimg_en_pnm(char *srcname, char *dstname, int to_gray)
|
||||
int convertir_fimg_en_pnm(char *srcname, char *dstname, int notused)
|
||||
{
|
||||
int foo, infos[3];
|
||||
FloatImg fimg, gris, *outptr;
|
||||
FloatImg fimg;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %25s ( '%s' '%s' %d )\n", __func__,
|
||||
srcname, dstname, to_gray);
|
||||
fprintf(stderr, ">>> %25s ( '%s' '%s' )\n", __func__, srcname, dstname);
|
||||
#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]));
|
||||
fprintf(stderr, "image '%s' is %d x %d\n",
|
||||
srcname, infos[0], infos[1]);
|
||||
}
|
||||
|
||||
foo = fimg_create_from_dump(srcname, &fimg);
|
||||
@ -36,86 +34,32 @@ if (foo) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
outptr = &fimg; /* safe default value */
|
||||
|
||||
if (to_gray) {
|
||||
puts("converting to gray...");
|
||||
foo = fimg_create(&gris, fimg.width, fimg.height, FIMG_TYPE_GRAY);
|
||||
if (foo) {
|
||||
fprintf(stderr, "err create gray %d\n", foo);
|
||||
return -2;
|
||||
}
|
||||
foo = fimg_mk_gray_from(&fimg, &gris, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "err mk gray %d\n", foo);
|
||||
return -4;
|
||||
}
|
||||
outptr = &gris;
|
||||
}
|
||||
|
||||
#if DEBUG_LEVEL > 1
|
||||
print_floatimg(outptr, "created fimg");
|
||||
print_floatimg(&fimg, "created fimg");
|
||||
#endif
|
||||
|
||||
foo = fimg_save_as_pnm(outptr, dstname, 0);
|
||||
foo = fimg_save_as_pnm(&fimg, dstname, 0);
|
||||
if(foo) { fprintf(stderr, "%p to '%s' -> %d\n", &fimg, dstname, foo); }
|
||||
|
||||
if (to_gray) {
|
||||
fimg_destroy(&gris);
|
||||
outptr = NULL;
|
||||
/* please run valgrind every hour */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
static void help(int flag)
|
||||
{
|
||||
if (flag) {
|
||||
fprintf(stderr, "conversion FIMG -> PNM 16 bits\n");
|
||||
fimg_print_version(1);
|
||||
}
|
||||
puts("usage :");
|
||||
puts("\tfimg2pnm [flags] infile.fimg outfile.pnm");
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int foo, opt;
|
||||
int to_gray = 0;
|
||||
int foo;
|
||||
|
||||
if (argc == 1) {
|
||||
help(0);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
while ((opt = getopt(argc, argv, "ghv")) != -1) {
|
||||
switch(opt) {
|
||||
case 'g': to_gray = 1;
|
||||
case 'v': verbosity++; break;
|
||||
case 'h': help(1); exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
/* mmmm, is it the good way ? */
|
||||
printf("argc %d -> %d\n", argc, argc-optind);
|
||||
for (foo=optind; foo<argc; foo++) {
|
||||
printf(" %d %s\n", foo, argv[foo]);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (2 != argc-optind) {
|
||||
fprintf(stderr, "error: %s need two filenames\n", argv[0]);
|
||||
if (3 != argc) {
|
||||
fimg_print_version(1);
|
||||
fprintf(stderr, "usage:\n\t%s foo.fimg bar.pnm\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( 0 != access(argv[optind], R_OK) ) { /* fimg is NOT readable */
|
||||
fprintf(stderr, "%s: %s don't exist.\n", argv[0], argv[optind]);
|
||||
if ( 0 != access(argv[1], R_OK|W_OK) ) { /* fimg is NOT readable */
|
||||
fprintf(stderr, "%s: %s don't exist.\n", argv[0], argv[1]);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
foo = convertir_fimg_en_pnm(argv[optind], argv[optind+1], to_gray);
|
||||
foo = convertir_fimg_en_pnm(argv[1], argv[2], 0);
|
||||
if (foo) fprintf(stderr, "conversion -> %d\n", foo);
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user