X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fgfxpoly.c;h=76352af7d7861157a1dc8f08a4c59f38d9cbd6c9;hp=d251881552aeb1fa711fb048341870b4e34a8f3b;hb=c41f4433d3e721073c60d55cd923a087761e45f7;hpb=2d74a1c07b95afe9e5b9666375021a3d4097cd90 diff --git a/lib/gfxpoly.c b/lib/gfxpoly.c index d251881..76352af 100644 --- a/lib/gfxpoly.c +++ b/lib/gfxpoly.c @@ -25,9 +25,15 @@ #include "gfxtools.h" #include "gfxpoly.h" #include "mem.h" +#ifdef INTERNAL_LIBART #include "art/libart.h" #include "art/art_svp_intersect.h" #include "art/art_svp_ops.h" +#else +#include +#include +#include +#endif #include "log.h" #include #include @@ -259,7 +265,7 @@ intbbox_t get_svp_bbox(ArtSVP*svp, double zoom) if(x1 < b.xmin) b.xmin = x1; if(y1 < b.ymin) b.ymin = y1; if(x2 > b.xmax) b.xmax = x2; - if(y2 > b.xmax) b.ymax = y2; + if(y2 > b.ymax) b.ymax = y2; } } if(b.xmax > (int)(MAX_WIDTH*zoom)) @@ -298,49 +304,37 @@ intbbox_t get_svp_bbox(ArtSVP*svp, double zoom) int compare_bitmaps(intbbox_t*bbox, unsigned char*data1, unsigned char*data2) { - int similar = 0; + if(!data1 || !data2) + return 0; int x,y; int height = bbox->height; int width = bbox->width; int width8 = (width+7) >> 3; unsigned char*l1 = &data1[width8]; unsigned char*l2 = &data2[width8]; - int fail = 0; for(y=1;ytype == gfx_moveTo) { vec[pos].code = ART_MOVETO_OPEN; vec[pos].x = l2->x; vec[pos].y = l2->y; + lastmove=pos; pos++; assert(pos<=len); } else if(l2->type == gfx_lineTo) { @@ -407,6 +403,16 @@ static ArtVpath* gfxline_to_ArtVpath(gfxline_t*line, char fill) } x = l2->x; y = l2->y; + + /* let closed line segments start w/ MOVETO instead of MOVETO_OPEN */ + if(lastmove>=0 && l2->type!=gfx_moveTo && (!l2->next || l2->next->type == gfx_moveTo)) { + if(vec[lastmove].x == l2->x && + vec[lastmove].y == l2->y) { + assert(vec[lastmove].code == ART_MOVETO_OPEN); + vec[lastmove].code = ART_MOVETO; + } + } + l2 = l2->next; } vec[pos++].code = ART_END; @@ -431,7 +437,7 @@ static ArtVpath* gfxline_to_ArtVpath(gfxline_t*line, char fill) } /* Find adjacent identical points. If an ajdacent pair of identical - points is found, the second is removed. + points is found, the second one is removed. So moveto x,y lineto x,y becomes moveto x,y lineto x,y lineto x,y becomes lineto x,y lineto x,y moveto x,y becomes lineto x,y @@ -523,7 +529,13 @@ static double find_shear_value(ArtSVP*svp) } if(!fail) break; - v = lrand48() / 2000000000.0; +#ifdef HAVE_LRAND48 + v = lrand48() / 2000000000.0;; +#elif HAVE_RAND + v = rand() / 2000000000.0; +#else +#error "no lrand48()/rand() implementation found" +#endif tries++; } return v; @@ -1121,14 +1133,9 @@ gfxline_t* gfxline_circularToEvenOdd(gfxline_t*line) msg(" Converting circular-filled gfxline of %d segments to even-odd filled gfxline", gfxline_len(line)); ArtSVP* svp = gfxfillToSVP(line, 1); - /* TODO: ART_WIND_RULE_POSITIVE means that a shape is visible if - positive and negative line segments add up to something positive. - I *think* that clockwise fill in PDF is defined in a way, however, - that the *last* shape's direction will determine whether something - is filled */ ArtSVP* svp_rewinded; - svp_rewinded = run_intersector(svp, ART_WIND_RULE_POSITIVE); + svp_rewinded = run_intersector(svp, ART_WIND_RULE_NONZERO); if(!svp_rewinded) { art_svp_free(svp); return 0;