Revision 23281

View differences:

trunk/libraries/libjni-potrace/resources/potrace-1.8/src/potrace_raster.c
1
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2 2
 *
3 3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4 4
 *
......
18 18
 */
19 19
#include <stdio.h>
20 20
#include <errno.h>
21
#include <math.h>
22
#include <getopt.h>
21 23

  
22 24
#include "main.h"
23 25
#include "platform.h"
......
255 257
	}
256 258
}
257 259

  
258
static FILE *my_fopen_read(char *filename) {
260
static FILE *my_fopen_read(const char *filename) {
259 261
	if (filename == NULL || strcmp(filename, "-") == 0) {
260 262
		return stdin;
261 263
	}
262 264
	return fopen(filename, "rb");
263 265
}
264 266

  
265
static FILE *my_fopen_write(char *filename) {
267
static FILE *my_fopen_write(const char *filename) {
266 268
	if (filename == NULL || strcmp(filename, "-") == 0) {
267 269
		return stdout;
268 270
	}
......
270 272
}
271 273

  
272 274
/* close a file, but do nothing is filename is NULL or "-" */
273
static void my_fclose(FILE *f, char *filename) {
275
static void my_fclose(FILE *f, const char *filename) {
274 276
	if (filename == NULL || strcmp(filename, "-") == 0) {
275 277
		return;
276 278
	}
......
337 339
	return;
338 340
}
339 341

  
340
static void dopts() {
342
struct pageformat_s {
343
  char *name;
344
  int w, h;
345
};
346
typedef struct pageformat_s pageformat_t;
347

  
348
/* dimensions of the various page formats, in postscript points */
349
static pageformat_t pageformat[] = {
350
  { "a4",        595,  842 },
351
  { "a3",        842, 1191 },
352
  { "a5",        421,  595 },
353
  { "b5",        516,  729 },
354
  { "letter",    612,  792 },
355
  { "legal",     612, 1008 },
356
  { "tabloid",   792, 1224 },
357
  { "statement", 396,  612 },
358
  { "executive", 540,  720 },
359
  { "folio",     612,  936 },
360
  { "quarto",    610,  780 },
361
  { "10x14",     720, 1008 },
362
  { NULL, 0, 0 },
363
};
364

  
365
struct turnpolicy_s {
366
  char *name;
367
  int n;
368
};
369
typedef struct turnpolicy_s turnpolicy_t;
370

  
371
/* names of turn policies */
372
static turnpolicy_t turnpolicy[] = {
373
  {"black",    POTRACE_TURNPOLICY_BLACK},
374
  {"white",    POTRACE_TURNPOLICY_WHITE},
375
  {"left",     POTRACE_TURNPOLICY_LEFT},
376
  {"right",    POTRACE_TURNPOLICY_RIGHT},
377
  {"minority", POTRACE_TURNPOLICY_MINORITY},
378
  {"majority", POTRACE_TURNPOLICY_MAJORITY},
379
  {"random",   POTRACE_TURNPOLICY_RANDOM},
380
  {NULL, 0},
381
};
382

  
383
static dim_t parse_dimension(char *s, char **endptr) {
384
  char *p;
385
  dim_t res;
386

  
387
  res.x = strtod(s, &p);
388
  res.d = 0;
389
  if (p!=s) {
390
    if (!strncasecmp(p, "in", 2)) {
391
      res.d = DIM_IN;
392
      p += 2;
393
    } else if (!strncasecmp(p, "cm", 2)) {
394
      res.d = DIM_CM;
395
      p += 2;
396
    } else if (!strncasecmp(p, "mm", 2)) {
397
      res.d = DIM_MM;
398
      p += 2;
399
    } else if (!strncasecmp(p, "pt", 2)) {
400
      res.d = DIM_PT;
401
      p += 2;
402
    }
403
  }
404
  if (endptr!=NULL) {
405
    *endptr = p;
406
  }
407
  return res;
408
}
409

  
410
/* parse a pair of dimensions, such as "8.5x11in", "30mmx4cm" */
411
static void parse_dimensions(char *s, char **endptr, dim_t *dxp, dim_t *dyp) {
412
  char *p, *q;
413
  dim_t dx, dy;
414

  
415
  dx = parse_dimension(s, &p);
416
  if (p==s) {
417
    goto fail;
418
  }
419
  if (*p != 'x') {
420
    goto fail;
421
  }
422
  p++;
423
  dy = parse_dimension(p, &q);
424
  if (q==p) {
425
    goto fail;
426
  }
427
  if (dx.d && !dy.d) {
428
    dy.d = dx.d;
429
  } else if (!dx.d && dy.d) {
430
    dx.d = dy.d;
431
  }
432
  *dxp = dx;
433
  *dyp = dy;
434
  if (endptr != NULL) {
435
    *endptr = q;
436
  }
437
  return;
438

  
439
 fail:
440
  dx.x = dx.d = dy.x = dy.d = 0;
441
  *dxp = dx;
442
  *dyp = dy;
443
  if (endptr != NULL) {
444
    *endptr = s;
445
  }
446
  return;
447
}
448

  
449
#define OPT_GROUP     300
450
#define OPT_OPAQUE    301
451
#define OPT_FILLCOLOR 302
452
#define OPT_PROGRESS  303
453

  
454
static struct option longopts[] = {
455
  {"help",          0, 0, 'h'},
456
  {"version",       0, 0, 'v'},
457
  {"license",       0, 0, 'l'},
458
  {"show-defaults", 0, 0, 'V'},
459
  {"progress",      0, 0, OPT_PROGRESS},
460
  {"width",         1, 0, 'W'},
461
  {"height",        1, 0, 'H'},
462
  {"resolution",    1, 0, 'r'},
463
  {"scale",         1, 0, 'x'},
464
  {"stretch",       1, 0, 'S'},
465
  {"margin",        1, 0, 'M'},
466
  {"leftmargin",    1, 0, 'L'},
467
  {"rightmargin",   1, 0, 'R'},
468
  {"topmargin",     1, 0, 'T'},
469
  {"bottommargin",  1, 0, 'B'},
470
  {"rotate",        1, 0, 'A'},
471
  {"pagesize",      1, 0, 'P'},
472
  {"turdsize",      1, 0, 't'},
473
  {"unit",          1, 0, 'u'},
474
  {"cleartext",     0, 0, 'c'},
475
  {"level2",        0, 0, '2'},
476
  {"level3",        0, 0, '3'},
477
  {"eps",           0, 0, 'e'},
478
  {"postscript",    0, 0, 'p'},
479
  {"svg",           0, 0, 's'},
480
  {"pgm",           0, 0, 'g'},
481
  {"backend",       1, 0, 'b'},
482
  {"debug",         1, 0, 'd'},
483
  {"color",         1, 0, 'C'},
484
  {"fillcolor",     1, 0, OPT_FILLCOLOR},
485
  {"turnpolicy",    1, 0, 'z'},
486
  {"gamma",         1, 0, 'G'},
487
  {"longcurve",     0, 0, 'n'},
488
  {"longcoding",    0, 0, 'q'},
489
  {"alphamax",      1, 0, 'a'},
490
  {"opttolerance",  1, 0, 'O'},
491
  {"output",        1, 0, 'o'},
492
  {"blacklevel",    1, 0, 'k'},
493
  {"invert",        0, 0, 'i'},
494
  {"opaque",        0, 0, OPT_OPAQUE},
495
  {"group",         0, 0, OPT_GROUP},
496

  
497
  {0, 0, 0, 0}
498
};
499

  
500
static char *shortopts = "hvlVW:H:r:x:S:M:L:R:T:B:A:P:t:u:c23epsgb:d:C:z:G:nqa:O:o:k:i";
501

  
502
static void dopts(int ac, char *av[]) {
341 503
	int c;
342 504
	char *p;
343 505
	int i, j, r;
......
380 542
	info.group = 0;
381 543
	info.fillcolor = 0xffffff;
382 544
	info.progress = 0;
383
}
384 545

  
385
/* ---------------------------------------------------------------------- */
386
/* Process one infile */
546
	while ((c = getopt_long(ac, av, shortopts, longopts, NULL)) != -1) {
547
		switch (c) {
548
			case 'h':
549
				fprintf(stdout, ""POTRACE" "VERSION". Transforms bitmaps into vector graphics.\n\n");
550
				usage(stdout);
551
				exit(0);
552
				break;
553
			case 'v':
554
				fprintf(stdout, ""POTRACE" "VERSION". Copyright (C) 2001-2007 Peter Selinger.\n");
555
				fprintf(stdout, "Library version: %s\n", potrace_version());
556
				exit(0);
557
				break;
558
			case 'l':
559
				fprintf(stdout, ""POTRACE" "VERSION". Copyright (C) 2001-2007 Peter Selinger.\n\n");
560
				license(stdout);
561
				exit(0);
562
				break;
563
			case 'V':
564
				fprintf(stdout, ""POTRACE" "VERSION". Copyright (C) 2001-2007 Peter Selinger.\n");
565
				show_defaults(stdout);
566
				exit(0);
567
				break;
568
			case OPT_PROGRESS:
569
				info.progress = 1;
570
				break;
571
			case 'W':
572
				info.width_d = parse_dimension(optarg, &p);
573
				if (*p) {
574
					fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg);
575
					exit(1);
576
				}
577
				break;
578
			case 'H':
579
				info.height_d = parse_dimension(optarg, &p);
580
				if (*p) {
581
					fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg);
582
					exit(1);
583
				}
584
				break;
585
			case 'r':
586
				parse_dimensions(optarg, &p, &dimx, &dimy);
587
				if (*p == 0 && dimx.d == 0 && dimy.d == 0) {
588
					info.rx = dimx.x;
589
					info.ry = dimy.x;
590
					break;
591
				}
592
				dim = parse_dimension(optarg, &p);
593
				if (*p == 0 && dim.d == 0) {
594
					info.rx = info.ry = dim.x;
595
					break;
596
				}
597
				fprintf(stderr, ""POTRACE": invalid resolution -- %s\n", optarg);
598
				exit(1);
599
				break;
600
			case 'x':
601
				parse_dimensions(optarg, &p, &dimx, &dimy);
602
				if (*p == 0 && dimx.d == 0 && dimy.d == 0) {
603
					info.sx = dimx.x;
604
					info.sy = dimy.x;
605
					break;
606
				}
607
				dim = parse_dimension(optarg, &p);
608
				if (*p == 0 && dim.d == 0) {
609
					info.sx = info.sy = dim.x;
610
					break;
611
				}
612
				fprintf(stderr, ""POTRACE": invalid scaling factor -- %s\n", optarg);
613
				exit(1);
614
				break;
615
			case 'S':
616
				info.stretch = atof(optarg);
617
				break;
618
			case 'M':
619
				info.lmar_d = parse_dimension(optarg, &p);
620
				if (*p) {
621
					fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg);
622
					exit(1);
623
				}
624
				info.rmar_d = info.tmar_d = info.bmar_d = info.lmar_d;
625
				break;
626
			case 'L':
627
				info.lmar_d = parse_dimension(optarg, &p);
628
				if (*p) {
629
					fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg);
630
					exit(1);
631
				}
632
				break;
633
			case 'R':
634
				info.rmar_d = parse_dimension(optarg, &p);
635
				if (*p) {
636
					fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg);
637
					exit(1);
638
				}
639
				break;
640
			case 'T':
641
				info.tmar_d = parse_dimension(optarg, &p);
642
				if (*p) {
643
					fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg);
644
					exit(1);
645
				}
646
				break;
647
			case 'B':
648
				info.bmar_d = parse_dimension(optarg, &p);
649
				if (*p) {
650
					fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg);
651
					exit(1);
652
				}
653
				break;
654
			case 'A':
655
				info.angle = strtod(optarg, &p);
656
				if (*p) {
657
					fprintf(stderr, ""POTRACE": invalid angle -- %s\n", optarg);
658
					exit(1);
659
				}
660
				break;
661
			case 'P':
662
				matches = 0;
663
				bestmatch = 0;
664
				for (i=0; pageformat[i].name!=NULL; i++) {
665
					if (strcasecmp(pageformat[i].name, optarg)==0) {
666
						matches = 1;
667
						bestmatch = i;
668
						break;
669
					} else if (strncasecmp(pageformat[i].name, optarg, strlen(optarg))==0) {
670
						/* don't allow partial match on "10x14" */
671
						if (optarg[0] != '1') {
672
							matches++;
673
							bestmatch = i;
674
						}
675
					}
676
				}
677
				if (matches == 1) {
678
					info.paperwidth = pageformat[bestmatch].w;
679
					info.paperheight = pageformat[bestmatch].h;
680
					break;
681
				}
682
				parse_dimensions(optarg, &p, &dimx, &dimy);
683
				if (*p == 0) {
684
					info.paperwidth = (int)rint(double_of_dim(dimx, DEFAULT_DIM));
685
					info.paperheight = (int)rint(double_of_dim(dimy, DEFAULT_DIM));
686
					break;
687
				}
688
				if (matches == 0) {
689
					fprintf(stderr, ""POTRACE": unrecognized page format -- %s\n", optarg);
690
				} else {
691
					fprintf(stderr, ""POTRACE": ambiguous page format -- %s\n", optarg);
692
				}
693
				j = fprintf(stderr, "Use one of: ");
694
				for (i=0; pageformat[i].name!=NULL; i++) {
695
					if (j + strlen(pageformat[i].name) > 75) {
696
						fprintf(stderr, "\n");
697
						j = 0;
698
					}
699
					j += fprintf(stderr, "%s, ", pageformat[i].name);
700
				}
701
				fprintf(stderr, "or specify <dim>x<dim>.\n");
702
				exit(1);
703
				break;
704
			case 't':
705
				info.param->turdsize = atoi(optarg);
706
				break;
707
			case 'u':
708
				info.unit = strtod(optarg, &p);
709
				if (*p) {
710
					fprintf(stderr, ""POTRACE": invalid unit -- %s\n", optarg);
711
					exit(1);
712
				}
713
				break;
714
			case 'c':
715
				info.pslevel = 2;
716
				info.compress = 0;
717
				break;
718
			case '2':
719
				info.pslevel = 2;
720
				info.compress = 1;
721
				break;
722
			case '3':
723
#ifdef HAVE_ZLIB
724
				info.pslevel = 3;
725
				info.compress = 1;
726
#else
727
				fprintf(stderr, ""POTRACE": option -3 not supported, using -2 instead.\n");
728
				info.pslevel = 2;
729
				info.compress = 1;
730
#endif
731
				break;
732
			case 'd':
733
				info.debug = atoi(optarg);
734
				break;
735
			case 'C':
736
				info.color = parse_color(optarg);
737
				if (info.color == -1) {
738
					fprintf(stderr, ""POTRACE": invalid color -- %s\n", optarg);
739
					exit(1);
740
				}
741
				break;
742
			case OPT_FILLCOLOR:
743
				info.fillcolor = parse_color(optarg);
744
				if (info.fillcolor == -1) {
745
					fprintf(stderr, ""POTRACE": invalid color -- %s\n", optarg);
746
					exit(1);
747
				}
748
				info.opaque = 1;
749
				break;
750
			case 'z':
751
				matches = 0;
752
				bestmatch = 0;
753
				for (i=0; turnpolicy[i].name!=NULL; i++) {
754
					if (strcasecmp(turnpolicy[i].name, optarg)==0) {
755
						matches = 1;
756
						bestmatch = i;
757
						break;
758
					} else if (strncasecmp(turnpolicy[i].name, optarg, strlen(optarg))==0) {
759
						matches++;
760
						bestmatch = i;
761
					}
762
				}
763
				if (matches == 1) {
764
					info.param->turnpolicy = turnpolicy[bestmatch].n;
765
					break;
766
				}
767
				if (matches == 0) {
768
					fprintf(stderr, ""POTRACE": unrecognized turnpolicy -- %s\n", optarg);
769
				} else {
770
					fprintf(stderr, ""POTRACE": ambiguous turnpolicy -- %s\n", optarg);
771
				}
772
				j = fprintf(stderr, "Use one of: ");
773
				for (i=0; turnpolicy[i].name!=NULL; i++) {
774
					if (j + strlen(turnpolicy[i].name) > 75) {
775
						fprintf(stderr, "\n");
776
						j = 0;
777
					}
778
					j += fprintf(stderr, "%s%s", turnpolicy[i].name, turnpolicy[i+1].name ? ", " : "");
779
				}
780
				fprintf(stderr, ".\n");
781
				exit(1);
782
				break;
783
			case 'G':
784
				info.gamma = atof(optarg);
785
				break;
786
			case 'n':
787
				info.param->opticurve = 0;
788
				break;
789
			case 'q':
790
				info.longcoding = 1;
791
				break;
792
			case 'a':
793
				info.param->alphamax = strtod(optarg, &p);
387 794

  
388
/* Process one or more bitmaps from fin, and write the results to fout
389
 using the page_f function of the appropriate backend. */
390

  
391
static void process_file(backend_t *b, const char *infile, const char *outfile, FILE *fin, FILE *fout) {
392
	int r;
393
	potrace_bitmap_t *bm = NULL;
394
	imginfo_t imginfo;
395
	int eof_flag = 0; /* to indicate premature eof */
396
	int count; /* number of bitmaps successfully processed, this file */
397
	potrace_state_t *st;
398
	simple_progress_t progress_data;
399

  
400
	for (count = 0;; count++) {
401
		/* read a bitmap */
402
		r = bm_read(fin, info.blacklevel, &bm);
403
		switch (r) {
404
			case -1: /* system error */
405
				fprintf(stderr, ""POTRACE": %s: %s\n", infile, strerror(errno));
406
				exit(2);
407
			case -2: /* corrupt file format */
408
				fprintf(stderr, ""POTRACE": %s: file format error: %s\n", infile, bm_read_error);
409
				exit(2);
410
			case -3: /* empty file */
411
				if (count > 0) { /* end of file */
412
					return;
795
				if (*p) {
796
					fprintf(stderr, ""POTRACE": invalid alphamax -- %s\n", optarg);
797
					exit(1);
413 798
				}
414
				fprintf(stderr, ""POTRACE": %s: empty file\n", infile);
415
				exit(2);
416
			case -4: /* wrong magic */
417
				if (count > 0) {
418
					fprintf(stderr, ""POTRACE": %s: warning: junk at end of file\n", infile);
419
					return;
799
				break;
800
			case 'O':
801
				info.param->opttolerance = strtod(optarg, &p);
802
				if (*p) {
803
					fprintf(stderr, ""POTRACE": invalid opttolerance -- %s\n", optarg);
804
					exit(1);
420 805
				}
421
				fprintf(stderr, ""POTRACE": %s: file format not recognized\n", infile);
422
				fprintf(stderr, "Possible input file formats are: pnm (pbm, pgm, ppm), bmp.\n");
423
				exit(2);
424
			case 1: /* unexpected end of file */
425
				fprintf(stderr, ""POTRACE": warning: %s: premature end of file\n", infile);
426
				eof_flag = 1;
427 806
				break;
807
			case 'o':
808
				free(info.outfile);
809
				info.outfile = strdup(optarg);
810
				break;
811
			case 'k':
812
				info.blacklevel = strtod(optarg, &p);
813
				if (*p) {
814
					fprintf(stderr, ""POTRACE": invalid blacklevel -- %s\n", optarg);
815
					exit(1);
816
				}
817
				break;
818
			case 'i':
819
				info.invert = 1;
820
				break;
821
			case OPT_OPAQUE:
822
				info.opaque = 1;
823
				break;
824
			case OPT_GROUP:
825
				info.group = 1;
826
				break;
827
			case '?':
828
				fprintf(stderr, "Try --help for more info\n");
829
				exit(1);
830
				break;
831
			default:
832
				fprintf(stderr, ""POTRACE": Unimplemented option -- %c\n", c);
833
				exit(1);
428 834
		}
429

  
430
		/* prepare progress bar, if requested */
431
		if (info.progress) {
432
			init_progress(&info.param->progress, &progress_data, infile, count);
433
		} else {
434
			info.param->progress.callback = NULL;
435
		}
436

  
437
		if (info.invert) {
438
			bm_invert(bm);
439
		}
440

  
441
		/* process the image */
442
		st = potrace_trace(info.param, bm);
443
		if (!st || st->status != POTRACE_STATUS_OK) {
444
			fprintf(stderr, ""POTRACE": %s: %s\n", infile, strerror(errno));
445
			exit(2);
446
		}
447

  
448
		/* calculate image dimensions */
449
		imginfo.pixwidth = bm->w;
450
		imginfo.pixheight = bm->h;
451
		calc_dimensions(&imginfo);
452

  
453
		bm_free(bm);
454

  
455
		r = b->page_f(fout, st->plist, &imginfo);
456
		if (r) {
457
			fprintf(stderr, ""POTRACE": %s: %s\n", outfile, strerror(errno));
458
			exit(2);
459
		}
460

  
461
		potrace_state_free(st);
462

  
463
		if (info.progress) {
464
			fprintf(stderr, "\n");
465
		}
466

  
467
		if (eof_flag || !b->multi) {
468
			return;
469
		}
470 835
	}
471
	/* not reached */
836
	info.infiles = &av[optind];
837
	info.infilecount = ac-optind;
472 838
}
473 839

  
474 840
static double* showList(potrace_path_t *plist) {
......
553 919
	return memory;
554 920
}
555 921

  
556
static double* process_buffer(backend_t *b, const long *inbuffer, int width, int height) {
922
static double* process_buffer(const long *inbuffer, int width, int height) {
557 923
	int r;
558 924
	double *memory;
559 925
	potrace_bitmap_t *bm = NULL;
......
562 928
	potrace_state_t *st;
563 929
	simple_progress_t progress_data;
564 930

  
565
	bm = (potrace_bitmap_t *) malloc(sizeof(potrace_bitmap_t));
931
	bm = (potrace_bitmap_t *) malloc (sizeof(potrace_bitmap_t));
566 932
	bm->w = width;
567 933
	bm->h = height;
568 934
	int dy = (width + 32 - 1) / 32;
569 935
	bm->dy = dy;
570 936

  
571
	bm->map = inbuffer;
937
	bm->map = (potrace_word *) inbuffer;
572 938

  
573 939
	/* prepare progress bar, if requested */
574 940
	info.param->progress.callback = NULL;
......
578 944
		bm_invert(bm);
579 945

  
580 946
	/* process the image */
947

  
581 948
	st = potrace_trace(info.param, bm);
582 949
	if (!st || st->status != POTRACE_STATUS_OK) {
583 950
		fprintf(stderr, ""POTRACE": %s\n", strerror(errno));
......
601 968
	return memory;
602 969
}
603 970

  
604
#define TRY(x) if (x) goto try_error
605

  
606
void vectorizar(const char *filein, const char *fileout) {
607
	backend_t *b; /* backend info */
608
	FILE *fin, *fout;
609

  
610
	printf("potrace_raster.c: vectorizar()\n");
611
	printf("potrace_raster.c: filein: %s\n", filein);
612
	printf("potrace_raster.c: fileout: %s\n", fileout);
613

  
971
double* vectorizarBuffer(const long *bufferIn, int width, int height, int argc, char *argv[]) {
614 972
	/* platform-specific initializations, e.g., set file i/o to binary */
615 973
	platform_init();
616 974

  
617
	/* process options */
618
	dopts();
975
	// Reiniciar el contador externo de los parametros
976
	optind = 1;
619 977

  
620
	b = info.backend;
621
	if (b == NULL) {
622
		fprintf(stderr, ""POTRACE": internal error: selected backend not found\n");
623
		exit(1);
624
	}
625

  
626
	fout = my_fopen_write(fileout);
627
	if (!fout) {
628
		fprintf(stderr, ""POTRACE": %s: %s\n", fileout, strerror(errno));
629
		exit(2);
630
	}
631
	if (b->init_f) {
632
		TRY(b->init_f(fout));
633
	}
634

  
635
	fin = my_fopen_read(filein);
636
	if (!fin) {
637
		fprintf(stderr, ""POTRACE": %s: %s\n", filein, strerror(errno));
638
		exit(2);
639
	}
640

  
641
	process_file(b, filein, fileout, fin, fout);
642
	my_fclose(fin, filein);
643

  
644
	if (b->term_f) {
645
		TRY(b->term_f(fout));
646
	}
647
	my_fclose(fout, fileout);
648

  
649
	try_error:
650
	fprintf(stderr, ""POTRACE": %s\n", strerror(errno));
651
	exit(2);
652
}
653

  
654
double* vectorizarBuffer(const long *bufferIn, int width, int height) {
655
	backend_t *b; /* backend info */
656

  
657
	/* platform-specific initializations, e.g., set file i/o to binary */
658
	platform_init();
659

  
660 978
	/* process options */
661
	dopts();
979
	dopts(argc, argv);
662 980

  
663
	b = info.backend;
664
	if (b == NULL) {
665
		fprintf(stderr, ""POTRACE": internal error: selected backend not found\n");
666
		exit(1);
667
	}
668

  
669
	return process_buffer(b, bufferIn, width, height);
981
	return process_buffer(bufferIn, width, height);
670 982
}
trunk/libraries/libjni-potrace/resources/potrace-1.8/src/potrace_raster.h
1
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2 2
 *
3 3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4 4
 *
......
91 91
};
92 92
typedef struct imginfo_s imginfo_t;
93 93

  
94
void vectorizar(const char *filein, const char *fileout);
95
double* vectorizarBuffer(const long *cbufferIn, int width, int height);
94
double* vectorizarBuffer(const long *cbufferIn, int width, int height, int argc, char *argv[]);
96 95

  
97 96
#endif /* POTRACE_RASTER_H */

Also available in: Unified diff