trying to do EXR io

This commit is contained in:
tth 2021-03-21 09:02:55 +01:00
parent 3f551e1473
commit 635b722635
10 changed files with 74 additions and 5 deletions

View File

@ -99,7 +99,7 @@ fprintf(stderr, " chainfilter %d\n", chainfilter);
fprintf(stderr, " destination %s\n", destination);
if (k) {
/* XXX */
}
return -1;

View File

@ -4,7 +4,7 @@
* http://la.buvette.org/photos/cumul
*/
#define FIMG_VERSION 125
#define FIMG_VERSION 126
/*
* in memory descriptor
@ -42,6 +42,7 @@ typedef struct {
#define FILE_TYPE_TIFF 5
#define FILE_TYPE_FITS 6
#define FILE_TYPE_BMP 7
#define FILE_TYPE_EXR 8
/* lib/contrast.c */
#define CONTRAST_NONE 0
@ -175,6 +176,7 @@ int fimg_save_G_as_fits(FloatImg *src, char *outname, int flags);
int fimg_save_B_as_fits(FloatImg *src, char *outname, int flags);
int fimg_write_as_tiff(FloatImg *src, char *fname, int flags);
int fimg_save_as_exr(FloatImg *src, char *outname, int flags);
/* mathematics operations */

View File

@ -5,7 +5,7 @@ DEPS = ../floatimg.h Makefile
OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \
fimg-libpnm.o rampes.o sfx0.o sfx1.o sfx2.o \
geometry.o rotate.o \
geometry.o rotate.o fimg-openexr.o \
equalize.o fimg-fits.o saturation.o histogram.o \
hsv.o classif.o contour2x2.o qsortrgb.o exporter.o \
displacement.o dithering.o plasmas.o
@ -42,6 +42,9 @@ fimg-bmp.o: fimg-bmp.c $(DEPS)
fimg-tiff.o: fimg-tiff.c $(DEPS)
gcc $(COPT) -c $<
fimg-openexr.o: fimg-openexr.c $(DEPS)
gcc $(COPT) -c $<
fimg-fits.o: fimg-fits.c $(DEPS)
gcc $(COPT) -I/usr/include/cfitsio/ -c $<

View File

@ -53,6 +53,9 @@ switch(filetype) {
case FILE_TYPE_BMP:
fprintf(stderr, "%s: file type BMP not implemented\n", __func__);
foo = -666;
case FILE_TYPE_EXR:
fprintf(stderr, "%s: file type EXR experimental\n", __func__);
foo = fimg_save_as_exr(pic, fname, 0);
default:
foo = -1789;
break;

30
funcs/fimg-openexr.c Normal file
View File

@ -0,0 +1,30 @@
/*
* Lecture/ecriture des images EXR
* -------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../floatimg.h"
extern int verbosity;
/* --------------------------------------------------------------------- */
int fimg_save_as_exr(FloatImg *src, char *outname, int flags)
{
// #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p '%s' 0x%X )\n", __func__, src, outname, flags);
// #endif
if (FIMG_TYPE_RGB != src->type) {
fprintf(stderr, "%s: src bad type %d\n", __func__, src->type);
return -2;
}
return -2;
}
/* --------------------------------------------------------------------- */

View File

@ -21,7 +21,7 @@ float global_fvalue;
/* --------------------------------------------------------------------- */
enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff,
Histo, Hsv, Classif, Ctr2x2, Qsortrgb,
Displace, ReadPNG, Plasmas, Hilight };
Displace, ReadPNG, Plasmas, Hilight, OpenEXR };
typedef struct {
char *name;
int Cmd;
@ -45,6 +45,7 @@ Command commands[] = {
{ "readpng", ReadPNG },
{ "plasma", Plasmas },
{ "hilight", Hilight },
{ "openexr", OpenEXR },
{ NULL, 0 }
} ;
@ -198,6 +199,9 @@ switch(opt) {
case Hilight:
foo = essai_highlights(filename, outfile, 0, global_fvalue);
break;
case OpenEXR:
foo = essai_openexr(filename, outfile, 0x55);
break;
default:
fprintf(stderr, "'%s' is a bad command\n", command);
exit(1);

View File

@ -16,6 +16,31 @@
extern int verbosity;
/* --------------------------------------------------------------------- */
/* nouveau 21 mars 2021 - rue d'Aragon */
int essai_openexr(char *inf, char *outf, int flags)
{
FloatImg src;
int foo;
fprintf(stderr, ">>> %s ( '%s' '%s' 0x%X )\n", __func__,
inf, outf, flags);
foo = fimg_create_from_dump(inf, &src);
if (0 != foo) {
fprintf(stderr, "%s: err %d loading image '%s'\n", __func__,
foo, inf);
return foo;
}
// fprintf(stderr, "image loaded at %p\n", &src);
fimg_describe(&src, "for save EXR test");
foo = fimg_save_as_exr(&src, outf, flags);
fimg_destroy(&src);
return -2;
}
/* --------------------------------------------------------------------- */
/* nouveau 20 mars 2021 - rue d'Aragon */
int essai_highlights(char *inf, char *outf, int ikoef, float fkoef)

View File

@ -26,4 +26,5 @@ int essai_histogramme(char *fname, int k);
int essai_lecture_png(char *fname, char *outfile, int notused);
int essai_highlights(char *inf, char *outf, int ikoef, float fkoef);
int essai_openexr(char *inf, char *outf, int flags);

View File

@ -73,6 +73,7 @@ if (!strcasecmp(cptr, ".png" )) return FILE_TYPE_PNG;
if (!strcasecmp(cptr, ".tiff")) return FILE_TYPE_TIFF;
if (!strcasecmp(cptr, ".tif" )) return FILE_TYPE_TIFF;
if (!strcasecmp(cptr, ".fits")) return FILE_TYPE_FITS;
if (!strcasecmp(cptr, ".exr")) return FILE_TYPE_EXR;
return -1;
}

View File

@ -2,7 +2,7 @@
# building the base library
#
COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=1
COPT = -Wall -fpic -g -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 \