/* * programme de test pour * les fonctions de base. */ #include #include #include #include #include #include "../floatimg.h" int verbosity; /* ---------------------------------------------------------------- */ int petit_dessin(FloatImg *img) { int x, y; float r, g, b; for (y=0; yheight; y++) { r = (float)y / (float)img->height; for (x=0; xwidth; x++) { g = (float)x / (float)img->width; b = 0.0;; fimg_plot_rgb(img, x, y, r, g, b); } } 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); } 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; } /* ---------------------------------------------------------------- */ int essai_contraste(char *fname) { int foo; FloatImg dessin; double maxi; foo = fimg_create_from_dump(fname, &dessin); maxi = (double)fimg_get_maxvalue(&dessin); fprintf(stderr, "avant valeur maxi = %f\n", maxi); fimg_power_2(&dessin, NULL, maxi); maxi = (double)fimg_get_maxvalue(&dessin); fprintf(stderr, "apres valeur maxi = %f\n", maxi); fimg_dump_to_file(&dessin, "dst.fimg", 0); fimg_destroy(&dessin); return -1; } /* ---------------------------------------------------------------- */ #define W 320 #define H 240 int main(int argc, char *argv[]) { int foo, idx, opt; // char outname[100]; int gray = 0; while ((opt = getopt(argc, argv, "gn:v")) != -1) { switch(opt) { case 'g': gray++; break; case 'n': foo=atoi(optarg); break; case 'v': verbosity++; break; } } if (verbosity) fimg_print_version(0); foo = essai_contraste("src.fimg"); fprintf(stderr, "retour essai contraste -> %d\n", foo); return 0; }