From 20d122890b453f0bb303dd59fc6e8db8beb4918a Mon Sep 17 00:00:00 2001 From: tth Date: Mon, 26 Aug 2019 01:47:05 +0200 Subject: [PATCH] simplified test prog --- lib/t.c | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/lib/t.c b/lib/t.c index b2f20134..b4e53942 100644 --- a/lib/t.c +++ b/lib/t.c @@ -35,20 +35,39 @@ return -1; int essai_2gray(FloatImg *picz, char *outname) { +int foo; +FloatImg gray; +fprintf(stderr, ">>> %s ( %p '%s' )\n", __func__, picz, outname); +foo = fimg_create(&gray, picz->width, picz->height, FIMG_TYPE_GRAY); +if (foo) { + fprintf(stderr, "%s : err %d on fimg create\n", __func__, foo); + exit(1); + } +foo = fimg_mk_gray_from(picz, &gray, 0); +if (foo) { + fprintf(stderr, "%s : err %d on fimg mk_gray_from\n", __func__, foo); + exit(1); + } -return -1; +foo = fimg_save_as_pnm(&gray, outname, 0); +if (foo) { + fprintf(stderr, "%s : err %d on save_as_pnm\n", __func__, foo); + exit(1); + } +fimg_destroy(&gray); + +return 0; } /* ---------------------------------------------------------------- */ -#define W 4000 -#define H 3000 +#define W 2048 +#define H 2048 int main(int argc, char *argv[]) { int foo; FloatImg dessin, noise, result; -int datas[3]; verbosity = 1; @@ -56,24 +75,14 @@ fimg_print_version(1); foo = fimg_create(&dessin, W, H, 3); petit_dessin(&dessin); -fimg_save_as_pnm(&dessin, "dessin.pnm", 0); - foo = fimg_create(&noise, W, H, 3); -fimg_drand48(&noise, 1.0); -fimg_save_as_pnm(&noise, "noise.pnm", 0); +fimg_drand48(&noise, 0.1); foo = fimg_create(&result, W, H, 3); - -foo = fimg_add(&dessin, &noise, &result); -fimg_save_as_pnm(&result, "r_add.pnm", 0); - +foo = fimg_mul(&dessin, &noise, &result); essai_2gray(&result, "gray.pnm"); - -foo = fimg_sub(&dessin, &noise, &result); -fimg_save_as_pnm(&result, "r_sub.pnm", 0); -foo = fimg_mul(&dessin, &noise, &result); -fimg_save_as_pnm(&result, "r_mul.pnm", 0); +fimg_destroy(&dessin), fimg_destroy(&noise), fimg_destroy(&result); return 0; }