reading PNG with pnglite is wtf

This commit is contained in:
le vieux
2020-11-09 14:27:28 +01:00
parent 0481c39c5e
commit b73c25f470
4 changed files with 58 additions and 38 deletions

View File

@@ -1,4 +1,5 @@
/*
* tests des fonctions diverses
*/
#include <stdio.h>
@@ -6,7 +7,8 @@
#include <string.h>
#include <pam.h>
#undef DEBUG_LEVEL
#define DEBUG_LEVEL 1
#include "../floatimg.h"
@@ -48,6 +50,8 @@ return 0;
/* --------------------------------------------------------------------- */
/*
* nouveau 7 octobre 2020 pendant sonoptic
*
* inspiration: Olivier Baudu
*/
int essai_qsort_rgb(char *infile, char *outfile)
@@ -314,10 +318,8 @@ if (foo) {
return -44;
}
fimg_filter_3x3(&src, &dst, &filter_a);
foo = fimg_clamp_negativ(&dst);
if (foo) {
@@ -539,6 +541,30 @@ fprintf(stderr, "make h deg -> %d\n", foo);
foo = fimg_save_as_pnm(&fimg, "vdeg.pnm", 0);
fprintf(stderr, "%s: save as pnm -> %d\n", __func__, foo);
return 0;
}
/* --------------------------------------------------------------------- */
int essai_lecture_png(char *fname, char *outfile, int notused)
{
FloatImg fimg;
int foo;
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
memset(&fimg, 0, sizeof(FloatImg));
foo = fimg_create_from_png(fname, &fimg);
if (foo) {
fprintf(stderr, "%s: createfrom -> %d\n", __func__, foo);
return foo;
}
fimg_describe(&fimg, "created from png");
foo = fimg_export_picture(&fimg, outfile, 0);
if (foo) {
fprintf(stderr, "%s : err %d saving result to %s\n", __func__,
foo, outfile);
return foo;
}
return 0;
}
/* --------------------------------------------------------------------- */
@@ -595,7 +621,7 @@ return 0;
/* --------------------------------------------------------------------- */
enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff,
Histo, Hsv, Classif, Ctr2x2, Qsortrgb,
Displace };
Displace, ReadPNG };
typedef struct {
char *name;
int Cmd;
@@ -616,6 +642,7 @@ Command commands[] = {
{ "ctr2x2", Ctr2x2 },
{ "qsortrgb", Qsortrgb },
{ "displace", Displace },
{ "readpng", ReadPNG },
{ NULL, 0 }
} ;
@@ -733,6 +760,9 @@ switch(opt) {
case Displace:
foo = essai_displacement(filename, outfile);
break;
case ReadPNG:
foo = essai_lecture_png(filename, outfile, 0);
break;
default:
fprintf(stderr, "%s : bad command\n", command);
exit(1);