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"
/* --------------------------------------------------------------------- */
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
@ -45,16 +26,12 @@ int datasize;
fprintf(stderr, ">>> %-25s ( '%s' %p )\n", __func__, filename, fimg);
#endif
/* We MUSTclear the fimg destination header first */
memset(fimg, 0, sizeof(FloatImg));
memset(&png, 0, sizeof(png_t));
png_init(NULL, NULL); /* this is VITAL ! */
foo = png_open_file_read(&png, filename);
if (PNG_NO_ERROR != foo) {
fprintf(stderr, "%s :\n\topen_file '%s' = %d %s\n", __func__,
filename, foo, pngerr2str(foo));
fprintf(stderr, "%s open_file '%s' -> %d\n", __func__, filename, foo);
return foo;
}
#if DEBUG_LEVEL > 1
@ -93,8 +70,8 @@ if (foo) {
foo = png_get_data(&png, datas);
if (PNG_NO_ERROR != foo) {
fprintf(stderr, "error in '%s' : read png -> %d %s\n",
__func__, foo, pngerr2str(foo));
fprintf(stderr, "error in '%s' : read png -> %d\n",
__func__, foo);
return foo;
}
@ -161,7 +138,6 @@ if (PNG_NO_ERROR != foo) {
__func__, foo);
return foo;
}
ptr = datas;
for (idx=0; idx<png.width * png.height; idx++) {
fimg->R[idx] = (float)*ptr++;

View File

@ -10,12 +10,6 @@
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 picsize, idx;
@ -37,7 +31,7 @@ if (FIMG_TYPE_RGB != d->type) {
return -9;
}
picsize = d->width * d->height * 3;
picsize = d->width * d->height * 2;
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);
foo = fimg_create_from_png("/home/tth/TMP/floatimg/s1.png", &dessin);
if (foo) {
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_from_png("/home/tth/TMP/floatimg/s2.png", &dessin);
foo = fimg_create_from_png("/home/tth/TMP/floatimg/s1.png", &noise);
foo = fimg_create(&result, W, H, 3);
#define NBRE 20
#define NBRE 42
for (idx=0; idx<NBRE; idx++) {
@ -116,7 +104,7 @@ for (idx=0; idx<NBRE; idx++) {
foo = fimg_interpolate(&dessin, &noise, &result, 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);
foo = fimg_save_as_pnm(&result, outname, 0);
}