forked from tTh/FloatImg
better handling of file extenstions
This commit is contained in:
parent
dcc1ff35cb
commit
0478bae6a3
@ -1,6 +1,9 @@
|
|||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
|
|
||||||
COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=0
|
# Please, use the 'Gloabl.makefile' system !
|
||||||
|
|
||||||
|
|
||||||
|
COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=1
|
||||||
DEPS = ../floatimg.h Makefile
|
DEPS = ../floatimg.h Makefile
|
||||||
|
|
||||||
OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \
|
OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \
|
||||||
|
@ -639,7 +639,7 @@ return 0;
|
|||||||
int essai_mire(char *outname, int notused)
|
int essai_mire(char *outname, int notused)
|
||||||
{
|
{
|
||||||
FloatImg fimg;
|
FloatImg fimg;
|
||||||
int re;
|
int re, foo;
|
||||||
|
|
||||||
fimg_create(&fimg, 1280, 960, FIMG_TYPE_RGB);
|
fimg_create(&fimg, 1280, 960, FIMG_TYPE_RGB);
|
||||||
|
|
||||||
@ -647,9 +647,10 @@ re = fimg_test_pattern(&fimg, 9, 1.0);
|
|||||||
if (re) {
|
if (re) {
|
||||||
fprintf(stderr, "fimg_test_pattern -> %d\n", re);
|
fprintf(stderr, "fimg_test_pattern -> %d\n", re);
|
||||||
}
|
}
|
||||||
fimg_export_picture(&fimg, "mire.pnm", 0);
|
foo = fimg_export_picture(&fimg, "mire.pnm", 0);
|
||||||
|
fprintf(stderr, "in %s, export give a %d value\n", __func__, foo);
|
||||||
|
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
int essai_rampes(void)
|
int essai_rampes(void)
|
||||||
|
@ -49,6 +49,25 @@ if (1 == foo) {
|
|||||||
*dptr = value;
|
*dptr = value;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int file_type_from_name(char *name)
|
||||||
|
{
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, name);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!strcasecmp(name, "pnm" )) return FILE_TYPE_PNM;
|
||||||
|
if (!strcasecmp(name, "fimg")) return FILE_TYPE_FIMG;
|
||||||
|
if (!strcasecmp(name, "tga" )) return FILE_TYPE_TGA;
|
||||||
|
if (!strcasecmp(name, "png" )) return FILE_TYPE_PNG;
|
||||||
|
if (!strcasecmp(name, "tiff")) return FILE_TYPE_TIFF;
|
||||||
|
if (!strcasecmp(name, "tif" )) return FILE_TYPE_TIFF;
|
||||||
|
if (!strcasecmp(name, "fits")) return FILE_TYPE_FITS;
|
||||||
|
if (!strcasecmp(name, "exr")) return FILE_TYPE_EXR;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
@ -56,6 +75,10 @@ int format_from_extension(char *fname)
|
|||||||
{
|
{
|
||||||
char *cptr;
|
char *cptr;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, fname);
|
||||||
|
#endif
|
||||||
|
|
||||||
cptr = rindex(fname, '.');
|
cptr = rindex(fname, '.');
|
||||||
if (NULL==cptr) {
|
if (NULL==cptr) {
|
||||||
fprintf(stderr, "No dot in %s\n", fname);
|
fprintf(stderr, "No dot in %s\n", fname);
|
||||||
@ -63,18 +86,28 @@ if (NULL==cptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, "[%s] --> [%s]\n", fname, cptr);
|
fprintf(stderr, "\t[%s] --> [%s]\n", fname, cptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!strcasecmp(cptr, ".pnm" )) return FILE_TYPE_PNM;
|
return file_type_from_name(cptr+1);
|
||||||
if (!strcasecmp(cptr, ".fimg")) return FILE_TYPE_FIMG;
|
}
|
||||||
if (!strcasecmp(cptr, ".tga" )) return FILE_TYPE_TGA;
|
/* --------------------------------------------------------------------- */
|
||||||
if (!strcasecmp(cptr, ".png" )) return FILE_TYPE_PNG;
|
char * extension_from_format(int fmt)
|
||||||
if (!strcasecmp(cptr, ".tiff")) return FILE_TYPE_TIFF;
|
{
|
||||||
if (!strcasecmp(cptr, ".tif" )) return FILE_TYPE_TIFF;
|
|
||||||
if (!strcasecmp(cptr, ".fits")) return FILE_TYPE_FITS;
|
switch (fmt) {
|
||||||
if (!strcasecmp(cptr, ".exr")) return FILE_TYPE_EXR;
|
case FILE_TYPE_FIMG: return ".fimg"; break;
|
||||||
|
case FILE_TYPE_PNM: return ".pnm"; break;
|
||||||
return -1;
|
case FILE_TYPE_PNG: return ".png"; break;
|
||||||
|
case FILE_TYPE_TIFF: return ".tiff"; break;
|
||||||
|
case FILE_TYPE_FITS: return ".fits"; break;
|
||||||
|
case FILE_TYPE_TGA: return ".tga"; break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "%s: bad %d fmt type\n", __func__, fmt);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "???";
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
Loading…
Reference in New Issue
Block a user