|
|
|
@ -12,7 +12,7 @@
@@ -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 */
@@ -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++) {
@@ -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) {
@@ -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);
@@ -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) {
@@ -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); |
|
|
|
|
|
|
|
|
|