forked from tTh/FloatImg
enhancing the new tool
This commit is contained in:
parent
69d94f59d3
commit
268a73ceb5
|
@ -6,7 +6,7 @@ cp floatimg.h /usr/local/include
|
|||
cp tools/mkfimg tools/fimg2pnm tools/fimgops \
|
||||
tools/fimg2png tools/fimg2tiff tools/fimg2fits \
|
||||
tools/png2fimg tools/fimgstats tools/fimgfx \
|
||||
tools/cumulfimgs \
|
||||
tools/cumulfimgs tools/fimg2text \
|
||||
/usr/local/bin
|
||||
|
||||
cp v4l2/grabvidseq v4l2/video-infos \
|
||||
|
|
|
@ -88,8 +88,9 @@ if (2 != argc-optind) {
|
|||
}
|
||||
|
||||
foo = convertir_fimg_en_PNG(argv[optind], argv[optind+1], to_gray);
|
||||
if (foo)
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
int verbosity;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
int export_as_machinable(FloatImg *src, char *fname, int flags)
|
||||
int export_as_machinable(FloatImg *src, char *fname, int steps, int flags)
|
||||
{
|
||||
FILE *fp;
|
||||
int x, y, idx;
|
||||
|
@ -32,11 +32,12 @@ if (strcmp("-", fname)) { /* real file */
|
|||
|
||||
idx = 0;
|
||||
fp = stdout; /* XXX */
|
||||
for (y=0; y<src->height; y++) {
|
||||
for (x=0; x<src->width; x++) {
|
||||
for (y=0; y<src->height; y+=steps) {
|
||||
for (x=0; x<src->width; x+=steps) {
|
||||
|
||||
fprintf(fp, "%d %d %d ", x, y, idx);
|
||||
fprintf(fp, " %f %f %f\n", src->R[idx], src->G[idx], src->B[idx]);
|
||||
fprintf(fp, "%d %d ", x, y);
|
||||
fprintf(fp, " %f %f %f\n",
|
||||
src->R[idx], src->G[idx], src->B[idx]);
|
||||
idx++;
|
||||
|
||||
}
|
||||
|
@ -45,7 +46,7 @@ for (y=0; y<src->height; y++) {
|
|||
return 0;
|
||||
}
|
||||
/* ------------------------------------------------------------------------- */
|
||||
int convertir_fimg_en_machinable(char *srcname, char *dstname, int grisaille)
|
||||
int convertir_fimg_en_machinable(char *srcname, char *dstname, int steps)
|
||||
{
|
||||
int foo, infos[3];
|
||||
FloatImg fimg;
|
||||
|
@ -78,7 +79,7 @@ if (verbosity) {
|
|||
fimg_describe(&fimg, srcname);
|
||||
}
|
||||
|
||||
foo = export_as_machinable(&fimg, dstname, 0);
|
||||
foo = export_as_machinable(&fimg, dstname, steps, 0);
|
||||
|
||||
fimg_destroy(&fimg);
|
||||
|
||||
|
@ -100,11 +101,13 @@ exit(0);
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
int foo, opt;
|
||||
int steps = 16;
|
||||
|
||||
while ((opt = getopt(argc, argv, "ghv")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "hs:v")) != -1) {
|
||||
switch(opt) {
|
||||
case 'v': verbosity++; break;
|
||||
case 'h': help(1); exit(1);
|
||||
case 's': steps = atoi(optarg); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +116,7 @@ if (1 != argc-optind) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
foo = convertir_fimg_en_machinable(argv[optind], "-", 0);
|
||||
foo = convertir_fimg_en_machinable(argv[optind], "-", steps);
|
||||
if (foo)
|
||||
fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo);
|
||||
|
||||
|
|
Loading…
Reference in New Issue