[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[mgp-users-jp 00356] Re: PS BoundingBox search length



>> Illustrator $B$,=PNO$7$?(B PS $B%U%!%$%k$r=PNO$7$h$&$H$7$?$i!"$I$&$7$F$b$&$^(B
>> $B$/$$$+$J$$$N$G%=!<%9$rFI$s$G$_$?$i!":G=i$N(B10$B9T$7$+8+$F$$$J$$$3$H$,$o$+(B
>> $B$j$^$7$?!#<j85$NNc$G$O(B19$B9TL\$K(B BoundingBox $B$N@_Dj$,$"$k$N$G!"(B30$B9T$KA}(B
>> $B$d$7$?$H$3$m$&$^$/$$$/$h$&$K$J$j$^$7$?!#$H$$$&$o$1$G!"2?9T$,E,Ev$+$O$o(B
>> $B$+$j$^$;$s$,!"$H$K$+$/(B10$B9T$G$O>/$J$9$.$^$9!#(B
>PosetScript $B%j%U%!%l%s%9!&%^%K%e%"%k(B ($BF|K\8lLu(B, $B%"%9%-!<=PHG(B
>$B6I(B) $B$K$h$k$H!"(B
(snip)
>%%EndComments $B$G;O$^$k9T$+!"(B``%%'' $B$b$7$/$O(B ``%!'' $B$G;O$^$i(B
>$B$J$$9T$,$/$k$^$G8+$k$N$,!"(BPostScript ($B$N(B DSC) $BE*$K$O@5$7$$$H(B
>$B;W$$$^$9!#(B

	quickhack$B$G$9$,$3$s$J$b$s$G!#(B

itojun


---
? hoge.mgp
? hoge.c
? test.mgp
? contrib/xmindpath/xmindpath
? contrib/xmindpath/configure.scan
? sample/test.mgp
? sample/.gscache.v6header.eps.306x203
? sample/.gscache.dad.eps.310x87
? sample/v6.mgp-
Index: draw.c
===================================================================
RCS file: /home/wide/itojun/cvsroot/mgp/kit/draw.c,v
retrieving revision 1.127
diff -c -r1.127 draw.c
*** draw.c	1998/10/23 06:44:41	1.127
--- draw.c	1998/11/02 15:50:07
***************
*** 2610,2617 ****
  		cleanup(-1);
  	}
  	if (ps_boundingbox(fullname, &x1, &y1, &x2, &y2) < 0) {
! 		fprintf(stderr, "failed to open postscript file %s\n",
! 			fullname);
  		cleanup(-1);
  	}
  
--- 2610,2616 ----
  		cleanup(-1);
  	}
  	if (ps_boundingbox(fullname, &x1, &y1, &x2, &y2) < 0) {
! 		/* error message generated in ps_boundingbox() */
  		cleanup(-1);
  	}
  
Index: postscript.c
===================================================================
RCS file: /home/wide/itojun/cvsroot/mgp/kit/postscript.c,v
retrieving revision 1.2
diff -c -r1.2 postscript.c
*** postscript.c	1998/08/26 05:29:57	1.2
--- postscript.c	1998/11/02 15:50:09
***************
*** 41,63 ****
  {
  	FILE *epsfp;
  	char buf[BUFSIZ];
- 	int i;
  	int x1, y1, x2, y2;
- #define SCANLINES	10	/*XXX*/
  
  	epsfp = NULL;
  	epsfp = fopen(fname, "r");
! 	if (!epsfp)
  		goto fail;
  
  	/* magic number */
! 	if (fgets(buf, sizeof(buf), epsfp) == NULL)
  		goto fail;
! 	if (buf[0] != '%' || buf[1] != '!')
  		goto fail;
! 	for (i = 0; i < SCANLINES; i++) {
  		if (fgets(buf, sizeof(buf), epsfp) == NULL)
! 			goto fail;
  		if (sscanf(buf, "%%%%BoundingBox: %d %d %d %d",
  				&x1, &y1, &x2, &y2) == 4) {
  			if (px1) *px1 = x1;
--- 41,72 ----
  {
  	FILE *epsfp;
  	char buf[BUFSIZ];
  	int x1, y1, x2, y2;
  
  	epsfp = NULL;
  	epsfp = fopen(fname, "r");
! 	if (!epsfp) {
! 		fprintf(stderr, "failed to open postscript file %s\n", fname);
  		goto fail;
+ 	}
  
  	/* magic number */
! 	if (fgets(buf, sizeof(buf), epsfp) == NULL) {
! 		fprintf(stderr, "error reading %s: file empty?\n", fname);
  		goto fail;
! 	}
! 	if (buf[0] != '%' || buf[1] != '!') {
! 		fprintf(stderr, "%s is not a postscript file, it seems\n",
! 			fname);
  		goto fail;
! 	}
! 	while (1) {
  		if (fgets(buf, sizeof(buf), epsfp) == NULL)
! 			break;
! 		if (buf[0] != '%')
! 			break;
! 		if (strncmp(buf, "%%EndComments", 12) == 0)
! 			break;
  		if (sscanf(buf, "%%%%BoundingBox: %d %d %d %d",
  				&x1, &y1, &x2, &y2) == 4) {
  			if (px1) *px1 = x1;
***************
*** 69,74 ****
--- 78,84 ----
  		}
  	}
  
+ 	fprintf(stderr, "No BoundingBox in %s\n", fname);
  fail:
  	if (epsfp)
  		fclose(epsfp);
Index: print.c
===================================================================
RCS file: /home/wide/itojun/cvsroot/mgp/kit/print.c,v
retrieving revision 1.67
diff -c -r1.67 print.c
*** print.c	1998/10/01 12:30:32	1.67
--- print.c	1998/11/02 15:50:31
***************
*** 1567,1572 ****
--- 1567,1573 ----
  	int x1, y1, x2, y2, height, width, sheight, swidth;
  	int xpos;
  	double xscale, yscale;
+ 	int noboundingbox;
  
  	if (fgets(line1, sizeof(line1), epsfp) == NULL) {
  		fprintf(stderr, "no first line in %s.\n", filename);
***************
*** 1577,1589 ****
  		exit(1);
  	}
  
! 	for (;;) {
! 		if (fgets(line2, sizeof(line2), epsfp) == NULL || line2[0] != '%') {
! 			fprintf(stderr, "no bounding box in %s.\n", filename);
! 			exit(1);
! 		}
! 		if (sscanf(line2, "%%%%BoundingBox: %d %d %d %d", &x1, &y1, &x2, &y2) == 4)
  			break;
  	}
  
  	/* width/height of original image */
--- 1578,1600 ----
  		exit(1);
  	}
  
! 	noboundingbox = 1;
! 	while (1) {
! 		if (fgets(line2, sizeof(line2), epsfp) == NULL)
! 			break;
! 		if (line2[0] != '%')
! 			break;
! 		if (strncmp(line2, "%%EndComments", 12) == 0)
! 			break;
! 		if (sscanf(line2, "%%%%BoundingBox: %d %d %d %d",
! 				&x1, &y1, &x2, &y2) == 4) {
! 			noboundingbox = 0;
  			break;
+ 		}
+ 	}
+ 	if (noboundingbox) {
+ 		fprintf(stderr, "no bounding box in %s.\n", filename);
+ 		exit(1);
  	}
  
  	/* width/height of original image */