X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fpdf%2FGFXOutputDev.cc;h=6c4a3a99c2f8d8544a2aedce54855ae9055c66d0;hp=eda022087d6bab398bab63367e8ee43aef03ce1f;hb=d37a4db40333c68f0b764e1aef6f784887429151;hpb=289ddc3e15e4bac347fb1a18732a6d3ec5657ffd diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index eda0220..6c4a3a9 100644 --- a/lib/pdf/GFXOutputDev.cc +++ b/lib/pdf/GFXOutputDev.cc @@ -132,7 +132,7 @@ static void dbg(const char*format, ...) if(!verbose) return; va_start(arglist, format); - vsprintf(buf, format, arglist); + vsnprintf(buf, sizeof(buf)-1, format, arglist); va_end(arglist); l = strlen(buf); while(l && buf[l-1]=='\n') { @@ -599,7 +599,7 @@ GFXOutputDev::GFXOutputDev(InfoOutputDev*info, PDFDoc*doc) this->config_remapunicode=0; this->config_transparent=0; this->config_extrafontdata = 0; - this->config_optimize_polygons = 0; + this->config_disable_polygon_conversion = 0; this->config_multiply = 1; this->page2page = 0; this->num_pages = 0; @@ -623,8 +623,8 @@ void GFXOutputDev::setParameter(const char*key, const char*value) this->config_multiply = atoi(value); if(this->config_multiply<1) this->config_multiply=1; - } else if(!strcmp(key,"optimize_polygons")) { - this->config_optimize_polygons = atoi(value); + } else if(!strcmp(key,"disable_polygon_conversion")) { + this->config_disable_polygon_conversion = atoi(value); } } @@ -791,6 +791,31 @@ void dump_outline(gfxline_t*line) } } +void gfxPath_dump(GfxPath*path) +{ + int num = path->getNumSubpaths(); + int t; + int cpos=0; + for(t = 0; t < num; t++) { + GfxSubpath *subpath = path->getSubpath(t); + int subnum = subpath->getNumPoints(); + int s; + for(s=0;sgetX(s); + double y=subpath->getY(s); + if(s==0 && !subpath->getCurve(s)) { + printf("M %f %f\n", x, y); + } else if(s==0 && subpath->getCurve(s)) { + printf("E %f %f\n", x, y); + } else if(subpath->getCurve(s)) { + printf("C %f %f\n", x, y); + } else { + printf("T %f %f\n", x, y); + } + } + } +} + gfxline_t* GFXOutputDev::gfxPath_to_gfxline(GfxState*state, GfxPath*path, int closed, int user_movex, int user_movey) { int num = path->getNumSubpaths(); @@ -1155,8 +1180,8 @@ void GFXOutputDev::strokeGfxline(GfxState *state, gfxline_t*line, int flags) } if(flags&STROKE_FILL) { - gfxpoly_t* poly = gfxpoly_strokeToPoly(line, width, capType, joinType, miterLimit); - gfxline_t*gfxline = gfxpoly_to_gfxline(poly); + gfxpoly_t* poly = gfxpoly_from_stroke(line, width, capType, joinType, miterLimit, DEFAULT_GRID); + gfxline_t*gfxline = gfxline_from_gfxpoly(poly); if(getLogLevel() >= LOGLEVEL_TRACE) { dump_outline(gfxline); } @@ -1170,7 +1195,7 @@ void GFXOutputDev::strokeGfxline(GfxState *state, gfxline_t*line, int flags) device->fill(device, gfxline, &col); } gfxline_free(gfxline); - gfxpoly_free(poly); + gfxpoly_destroy(poly); } else { if(flags&STROKE_CLIP) msg(" Stroke&clip not supported at the same time"); @@ -1222,8 +1247,8 @@ void GFXOutputDev::clip(GfxState *state) GfxPath * path = state->getPath(); msg(" clip"); gfxline_t*line = gfxPath_to_gfxline(state, path, 1, user_movex + clipmovex, user_movey + clipmovey); - if(config_optimize_polygons) { - gfxline_t*line2 = gfxline_circularToEvenOdd(line); + if(!config_disable_polygon_conversion) { + gfxline_t*line2 = gfxpoly_circular_to_evenodd(line, DEFAULT_GRID); gfxline_free(line); line = line2; } @@ -2443,8 +2468,8 @@ void GFXOutputDev::fill(GfxState *state) GfxPath * path = state->getPath(); gfxline_t*line= gfxPath_to_gfxline(state, path, 1, user_movex + clipmovex, user_movey + clipmovey); - if(config_optimize_polygons) { - gfxline_t*line2 = gfxline_circularToEvenOdd(line); + if(!config_disable_polygon_conversion) { + gfxline_t*line2 = gfxpoly_circular_to_evenodd(line, DEFAULT_GRID); gfxline_free(line); line = line2; } @@ -2479,8 +2504,8 @@ void addGlobalFont(const char*filename) memset(f, 0, sizeof(fontfile_t)); f->filename = filename; int len = strlen(filename); - char*r1 = strrchr(filename, '/'); - char*r2 = strrchr(filename, '\\'); + char*r1 = strrchr((char*)filename, '/'); + char*r2 = strrchr((char*)filename, '\\'); if(r2>r1) r1 = r2; if(r1) { @@ -2598,9 +2623,9 @@ void GFXOutputDev::endTransparencyGroup(GfxState *state) this->device = states[statepos].olddevice; if(!this->device) { - msg(" bad state nesting in transparency group- PDF file broken?"); - /* if these errors occur more often, we should build a seperate - transparency group stack, like xpdf/SplashOutputDev.cc does */ + msg(" Bad state nesting in transparency group"); + msg(" Notice: this is a known problem, which will be fixed in 0.9.1"); + msg(" In the meantime, please convert the file with -s poly2bitmap"); restoreState(state); this->device = states[statepos].olddevice; }