Compare commits

..

No commits in common. "f109077b507f0f15f4c24d85975b292db8c2bf09" and "2f3a8870c4a7dd090b10abed5588096993c3d57d" have entirely different histories.

3 changed files with 9 additions and 51 deletions

View File

@ -10,25 +10,6 @@
#include "../floatimg.h" #include "../floatimg.h"
/* --------------------------------------------------------------------- */
static char *pngerr2str(int code)
{
switch (code) {
case 1: return "Done";
case 0: return "No error";
case -1: return "File error";
case -2: return "Header error";
case -3: return "IO error";
case -4: return "EOF error";
case -5: return "CRC error";
case -6: return "Memory error";
case -7: return "Zlib error";
case -8: return "Unknow filter";
case -9: return "Not supported";
case -10: return "Wrong arguments";
}
return "*unknow*";
}
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* /*
* warning : this func has been tested only with * warning : this func has been tested only with
@ -45,16 +26,12 @@ int datasize;
fprintf(stderr, ">>> %-25s ( '%s' %p )\n", __func__, filename, fimg); fprintf(stderr, ">>> %-25s ( '%s' %p )\n", __func__, filename, fimg);
#endif #endif
/* We MUSTclear the fimg destination header first */
memset(fimg, 0, sizeof(FloatImg));
memset(&png, 0, sizeof(png_t)); memset(&png, 0, sizeof(png_t));
png_init(NULL, NULL); /* this is VITAL ! */ png_init(NULL, NULL); /* this is VITAL ! */
foo = png_open_file_read(&png, filename); foo = png_open_file_read(&png, filename);
if (PNG_NO_ERROR != foo) { if (PNG_NO_ERROR != foo) {
fprintf(stderr, "%s :\n\topen_file '%s' = %d %s\n", __func__, fprintf(stderr, "%s open_file '%s' -> %d\n", __func__, filename, foo);
filename, foo, pngerr2str(foo));
return foo; return foo;
} }
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
@ -93,8 +70,8 @@ if (foo) {
foo = png_get_data(&png, datas); foo = png_get_data(&png, datas);
if (PNG_NO_ERROR != foo) { if (PNG_NO_ERROR != foo) {
fprintf(stderr, "error in '%s' : read png -> %d %s\n", fprintf(stderr, "error in '%s' : read png -> %d\n",
__func__, foo, pngerr2str(foo)); __func__, foo);
return foo; return foo;
} }
@ -161,7 +138,6 @@ if (PNG_NO_ERROR != foo) {
__func__, foo); __func__, foo);
return foo; return foo;
} }
ptr = datas; ptr = datas;
for (idx=0; idx<png.width * png.height; idx++) { for (idx=0; idx<png.width * png.height; idx++) {
fimg->R[idx] = (float)*ptr++; fimg->R[idx] = (float)*ptr++;

View File

@ -10,12 +10,6 @@
int verbosity; int verbosity;
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
static int gray_interpolate(FloatImg *s1, FloatImg *s2, FloatImg *d, float coef)
{
return -1;
}
/* ---------------------------------------------------------------- */
int fimg_interpolate(FloatImg *s1, FloatImg *s2, FloatImg *d, float coef) int fimg_interpolate(FloatImg *s1, FloatImg *s2, FloatImg *d, float coef)
{ {
int picsize, idx; int picsize, idx;
@ -37,7 +31,7 @@ if (FIMG_TYPE_RGB != d->type) {
return -9; return -9;
} }
picsize = d->width * d->height * 3; picsize = d->width * d->height * 2;
for (idx=0; idx<picsize; idx++) { for (idx=0; idx<picsize; idx++) {
@ -45,6 +39,6 @@ for (idx=0; idx<picsize; idx++) {
} }
return 0; return -1;
} }
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */

20
lib/t.c
View File

@ -88,24 +88,12 @@ verbosity = 1;
fimg_print_version(1); fimg_print_version(1);
foo = fimg_create_from_png("/home/tth/TMP/floatimg/s1.png", &dessin); foo = fimg_create_from_png("/home/tth/TMP/floatimg/s2.png", &dessin);
if (foo) { foo = fimg_create_from_png("/home/tth/TMP/floatimg/s1.png", &noise);
fprintf(stderr, "s1 load err %d\n", foo);
exit(1);
}
fimg_describe(&dessin, "s1 dessin");
fimg_to_gray(&dessin);
foo = fimg_create_from_png("/home/tth/TMP/floatimg/s2.png", &noise);
if (foo) {
fprintf(stderr, "s2 load err %d\n", foo);
exit(1);
}
fimg_describe(&noise, "s2 noise");
foo = fimg_create(&result, W, H, 3); foo = fimg_create(&result, W, H, 3);
#define NBRE 20 #define NBRE 42
for (idx=0; idx<NBRE; idx++) { for (idx=0; idx<NBRE; idx++) {
@ -116,7 +104,7 @@ for (idx=0; idx<NBRE; idx++) {
foo = fimg_interpolate(&dessin, &noise, &result, coef); foo = fimg_interpolate(&dessin, &noise, &result, coef);
printf("%6d %9.6f\n", idx, coef); printf("%6d %9.6f\n", idx, coef);
// fimg_to_gray(&result); fimg_to_gray(&result);
sprintf(outname, "/home/tth/TMP/floatimg/%05d.pnm", idx); sprintf(outname, "/home/tth/TMP/floatimg/%05d.pnm", idx);
foo = fimg_save_as_pnm(&result, outname, 0); foo = fimg_save_as_pnm(&result, outname, 0);
} }