FloatImg sources upgraded to version 147

This commit is contained in:
Mutah 2021-05-13 12:32:20 +02:00
parent bbc0309591
commit 3dfaff7df4
4 changed files with 41 additions and 11 deletions

View File

@ -4,7 +4,7 @@
* http://la.buvette.org/photos/cumul
*/
#define FIMG_VERSION 145
#define FIMG_VERSION 147
/*
* in memory descriptor
@ -218,6 +218,7 @@ int fimg_save_as_bmp(FloatImg *src, char *outname, int flags);
int fimg_test_pattern(FloatImg *fimg, int type, double dval);
int fimg_draw_something(FloatImg *fimg);
int fimg_mircol_1(FloatImg *dst, float mval);
int fimg_multirandom(FloatImg *fimg, long nbpass);
/* file is 'funcs/utils.c' */

View File

@ -59,7 +59,7 @@ for (y=0; y<psrc->height; y++) {
fimg_get_rgb(psrc, x, y, rgb);
dispx = (float)x + (rgb[1]/dltg * 20.0);
dispy = (float)y + (rgb[2]/dltb * 10.0);
dispy = (float)y + (rgb[2]/dltb * 20.0);
dstx = (int)roundf(dispx - 10.0);
dsty = (int)roundf(dispy - 10.0);

View File

@ -86,6 +86,24 @@ for (y=1; y<fimg->height; y++) {
return 0;
}
/* --------------------------------------------------------------------- */
int fimg_mircol_1(FloatImg *dst, float mval)
{
int x, y;
float fx, fy, rgb[3];
for (y=0; y<dst->height; y++) {
fy = (float)y / (float)dst->height;
for (x=0; x<dst->width; x++) {
fx = (float)x / (float)dst->width;
rgb[0] = mval * fx;
rgb[1] = mval * ((fx+fy)/2.0);
rgb[2] = mval * fy;
fimg_put_rgb(dst, x, y, rgb);
}
}
return -1;
}
/* --------------------------------------------------------------------- */
int fimg_multirandom(FloatImg *fimg, long nbpass)
{
int foo, x, y;

View File

@ -20,7 +20,8 @@ int verbosity;
#define T_HDEG_A 4
#define T_VDEG_A 5
#define T_TPAT0 6
#define T_MIRCOL1 7
#define T_BLOUP 8
typedef struct {
int code;
char *name;
@ -34,10 +35,12 @@ Type types[] = {
{ T_HDEG_A, "hdeg" },
{ T_VDEG_A, "vdeg" },
{ T_TPAT0, "tpat0" },
{ T_MIRCOL1, "mircol1" },
{ T_BLOUP, "bloup" },
{ 0, NULL }
};
static int get_type(char *name)
static int get_type_by_name(char *name)
{
Type *type;
@ -58,15 +61,18 @@ return -1;
/* --------------------------------------------------------------------- */
static void help(int lj)
{
int foo;
int foo, cc;
puts("Usage:\tmkfimg [options] quux.fimg width height");
puts("\t-k N.N\tgive a float parameter");
fputs("\t-t bla\thowto make the pic :\n\t\t", stdout);
for (foo=0; types[foo].code; foo++) {
printf("%s ", types[foo].name);
fputs("\t-t bla\thowto make the pic :\n\t\t| ", stdout);
for (foo=cc=0; types[foo].code; foo++) {
cc += printf("%s ", types[foo].name);
if (cc>42) { cc=0; printf("\n\t\t| "); }
}
puts("\n\t-v\tincrease verbosity");
if (verbosity) {
@ -92,7 +98,8 @@ while ((opt = getopt(argc, argv, "hk:t:v")) != -1) {
switch(opt) {
case 'h': help(0); break;
case 'k': fvalue = atof(optarg); break;
case 't': type = get_type(tname=optarg); break;
case 't': type = get_type_by_name(tname=optarg);
break;
case 'v': verbosity++; break;
}
}
@ -122,13 +129,15 @@ switch (nbargs) {
height = atoi(argv[optind+2]);
break;
default:
fprintf(stderr, "%s need filename, width & height\n", argv[0]);
fprintf(stderr, "%s need filename, width & height\n",
argv[0]);
exit(1);
}
fname = argv[optind];
if (verbosity>1) fprintf(stderr, "*** mkfimg *** %s %s\n", __DATE__, __TIME__);
if (verbosity>1) fprintf(stderr, "*** mkfimg *** %s %s\n",
__DATE__, __TIME__);
if (verbosity) fprintf(stderr, "making '%s' %dx%d, type %d\n",
fname, width, height, type);
@ -149,6 +158,8 @@ switch(type) {
case T_HDEG_A: fimg_hdeg_a(&fimg, 1.0); break;
case T_VDEG_A: fimg_vdeg_a(&fimg, 1.0); break;
case T_TPAT0: fimg_test_pattern(&fimg, 0, fvalue); break;
case T_MIRCOL1: fimg_mircol_1(&fimg, fvalue); break;
case T_BLOUP: fimg_draw_something(&fimg); break;
case -1: exit(1);
}