going for a real ride ?
This commit is contained in:
parent
4556887358
commit
149bd0b06c
@ -16,7 +16,8 @@ int verbosity;
|
|||||||
int export_as_machinable(FloatImg *src, char *fname, int steps, int flags)
|
int export_as_machinable(FloatImg *src, char *fname, int steps, int flags)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int x, y, idx;
|
int x, y;
|
||||||
|
float rgb[3];
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %25s ( %p '%s' %d )\n", __func__,
|
fprintf(stderr, ">>> %25s ( %p '%s' %d )\n", __func__,
|
||||||
@ -25,22 +26,19 @@ fprintf(stderr, ">>> %25s ( %p '%s' %d )\n", __func__,
|
|||||||
|
|
||||||
fp = NULL; /* molly guard */
|
fp = NULL; /* molly guard */
|
||||||
if (strcmp("-", fname)) { /* real file */
|
if (strcmp("-", fname)) { /* real file */
|
||||||
fprintf(stderr, "real file\n");
|
fprintf(stderr, "real file '%s'\n", fname);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "kitchen sink\n");
|
fprintf(stderr, "kitchen sink\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
idx = 0;
|
|
||||||
fp = stdout; /* XXX */
|
fp = stdout; /* XXX */
|
||||||
for (y=0; y<src->height; y+=steps) {
|
for (y=0; y<src->height; y+=steps) {
|
||||||
for (x=0; x<src->width; x+=steps) {
|
for (x=0; x<src->width; x+=steps) {
|
||||||
|
|
||||||
|
fimg_get_rgb(src, x, y, rgb);
|
||||||
fprintf(fp, "%d %d ", x, y);
|
fprintf(fp, "%d %d ", x, y);
|
||||||
fprintf(fp, " %f %f %f\n",
|
fprintf(fp, "%f %f %f\n", rgb[0], rgb[1], rgb[2]);
|
||||||
src->R[idx], src->G[idx], src->B[idx]);
|
|
||||||
idx++;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,13 +55,19 @@ fprintf(stderr, ">>> %s ( %p %g )\n", __func__, pimg, vmax);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
foo = fimg_get_minmax_rgb(pimg, mmv);
|
foo = fimg_get_minmax_rgb(pimg, mmv);
|
||||||
// fimg_print_minmax(mmv, "norm it ?");
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: ABEND\n", __func__);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
maxi = mmv[1];
|
maxi = mmv[1];
|
||||||
if (mmv[3] > maxi) maxi = mmv[3];
|
if (mmv[3] > maxi) maxi = mmv[3];
|
||||||
if (mmv[5] > maxi) maxi = mmv[5];
|
if (mmv[5] > maxi) maxi = mmv[5];
|
||||||
// fprintf(stderr, "maximum = %f\n", maxi);
|
|
||||||
coef = vmax / maxi;
|
coef = vmax / maxi;
|
||||||
// fprintf(stderr, "coef = %f\n", coef);
|
if (verbosity) {
|
||||||
|
fprintf(stderr, "mins %f %f %f\n", mmv[0], mmv[2], mmv[4]);
|
||||||
|
fprintf(stderr, "maxs %f %f %f\n", mmv[1], mmv[3], mmv[5]);
|
||||||
|
fprintf(stderr, "coef = %f\n", coef);
|
||||||
|
}
|
||||||
|
|
||||||
sz = pimg->width * pimg->height;
|
sz = pimg->width * pimg->height;
|
||||||
|
|
||||||
@ -108,9 +112,10 @@ if (foo) {
|
|||||||
|
|
||||||
if (verbosity) {
|
if (verbosity) {
|
||||||
fimg_describe(&fimg, srcname);
|
fimg_describe(&fimg, srcname);
|
||||||
|
fprintf(stderr, "normalize to %f\n", norm);
|
||||||
}
|
}
|
||||||
if (norm > 0.0) {
|
if (norm > 0.0) {
|
||||||
fprintf(stderr, "normalize %p\n", &fimg);
|
// fprintf(stderr, "normalize %p\n", &fimg);
|
||||||
foo = normalize(&fimg, norm);
|
foo = normalize(&fimg, norm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +144,7 @@ int foo, opt;
|
|||||||
int steps = 16;
|
int steps = 16;
|
||||||
float norm_val = 222.0; /* < 0 : don't normalize */
|
float norm_val = 222.0; /* < 0 : don't normalize */
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "hs:v")) != -1) {
|
while ((opt = getopt(argc, argv, "hn:s:v")) != -1) {
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
case 'v': verbosity++; break;
|
case 'v': verbosity++; break;
|
||||||
case 'h': help(1); exit(1);
|
case 'h': help(1); exit(1);
|
||||||
@ -154,8 +159,9 @@ if (1 != argc-optind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foo = convertir_fimg_en_machinable(argv[optind], "-", steps, norm_val);
|
foo = convertir_fimg_en_machinable(argv[optind], "-", steps, norm_val);
|
||||||
if (foo)
|
if (foo) {
|
||||||
fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo);
|
fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user