Hi, And another small fix for xpdf-3.03 branch, on running using poppler.
bitmap and poly2bitmap where not adding a white background to the document nor adding an option to allow this as a parameter, as vector output does. So I added support for a new parameter flag "transparent", that fills the output with a white background in case it is not provided. I have the changes in my github. The relevant commit is the last one. https://github.com/jdapena/swftools/tree/fb905 I'm also attaching the commit. Br, -- Jose Dapena Paz <[email protected]> Igalia
commit b669cab049667c11f04782078fd5c84c4ac6b631 Author: José Dapena Paz <[email protected]> Date: Wed Aug 8 15:50:30 2012 +0200 pdf2swf does not add white background on bitmap and poly2bitmap output modes bitmap and poly2bitmap where not adding a white background to the document nor adding an option to allow this as a parameter, as vector output does. So I added support for a new parameter flag "transparent", that fills the output with a white background in case it is not provided. https://forge.igalia.com/issues/905 diff --git a/lib/pdf/BitmapOutputDev.cc b/lib/pdf/BitmapOutputDev.cc index 5b24dfe..c96ba2e 100644 --- a/lib/pdf/BitmapOutputDev.cc +++ b/lib/pdf/BitmapOutputDev.cc @@ -103,6 +103,7 @@ BitmapOutputDev::BitmapOutputDev(InfoOutputDev*info, PDFDoc*doc, int*page2page, this->config_optimizeplaincolorfills = 0; this->config_skewedtobitmap = 0; this->config_alphatobitmap = 0; + this->config_transparent = 0; this->bboxpath = 0; //this->clipdev = 0; //this->clipstates = 0; @@ -167,6 +168,8 @@ void BitmapOutputDev::setParameter(const char*key, const char*value) this->config_skewedtobitmap = atoi(value); } else if(!strcmp(key, "alphatobitmap")) { this->config_alphatobitmap = atoi(value); + } else if(!strcmp(key, "transparent")) { + this->config_transparent = atoi(value); } this->gfxdev->setParameter(key, value); @@ -999,6 +1002,20 @@ GBool BitmapOutputDev::checkPageSlice(Page *page, double hDPI, double vDPI, void BitmapOutputDev::beginPage(GfxState *state, int pageNum) { + gfxcolor_t white = {255,255,255,255}; + gfxline_t clippath[5]; + + clippath[0].type = gfx_moveTo;clippath[0].x = 0; clippath[0].y = 0; clippath[0].next = &clippath[1]; + clippath[1].type = gfx_lineTo;clippath[1].x = width; clippath[1].y = 0; clippath[1].next = &clippath[2]; + clippath[2].type = gfx_lineTo;clippath[2].x = width; clippath[2].y = height; clippath[2].next = &clippath[3]; + clippath[3].type = gfx_lineTo;clippath[3].x = 0; clippath[3].y = height; clippath[3].next = &clippath[4]; + clippath[4].type = gfx_lineTo;clippath[4].x = 0; clippath[4].y = 0; clippath[4].next = 0; + + if(!config_transparent) { + msg("<debug> drawing white background"); + dev->fill(dev, clippath, &white); + } + rgbdev->startPage(pageNum, state); boolpolydev->startPage(pageNum, state); booltextdev->startPage(pageNum, state); diff --git a/lib/pdf/BitmapOutputDev.h b/lib/pdf/BitmapOutputDev.h index 1ad7ec6..0b412d3 100644 --- a/lib/pdf/BitmapOutputDev.h +++ b/lib/pdf/BitmapOutputDev.h @@ -204,6 +204,7 @@ private: char config_optimizeplaincolorfills; char config_skewedtobitmap; char config_alphatobitmap; + char config_transparent; int text_x1,text_y1,text_x2,text_y2; diff --git a/lib/pdf/FullBitmapOutputDev.cc b/lib/pdf/FullBitmapOutputDev.cc index 6b0a854..cb9969c 100644 --- a/lib/pdf/FullBitmapOutputDev.cc +++ b/lib/pdf/FullBitmapOutputDev.cc @@ -43,6 +43,8 @@ static SplashColor splash_black = {0,0,0}; FullBitmapOutputDev::FullBitmapOutputDev(InfoOutputDev*info, PDFDoc*doc, int*page2page, int num_pages, int x, int y, int x1, int y1, int x2, int y2) :CommonOutputDev(info, doc, page2page, num_pages, x, y, x1, y1, x2, y2) { + this->config_transparent = 0; + this->doc = doc; this->xref = doc->getXRef(); @@ -74,6 +76,9 @@ void FullBitmapOutputDev::setDevice(gfxdevice_t*dev) void FullBitmapOutputDev::setParameter(const char*key, const char*value) { + if(!strcmp(key,"transparent")) { + this->config_transparent = atoi(value); + } } static void getBitmapBBox(Guchar*alpha, int width, int height, int*xmin, int*ymin, int*xmax, int*ymax) { @@ -192,6 +197,20 @@ GBool FullBitmapOutputDev::checkPageSlice(Page *page, double hDPI, double vDPI, void FullBitmapOutputDev::beginPage(GfxState *state, int pageNum) { + gfxcolor_t white = {255,255,255,255}; + gfxline_t clippath[5]; + + clippath[0].type = gfx_moveTo;clippath[0].x = 0; clippath[0].y = 0; clippath[0].next = &clippath[1]; + clippath[1].type = gfx_lineTo;clippath[1].x = width; clippath[1].y = 0; clippath[1].next = &clippath[2]; + clippath[2].type = gfx_lineTo;clippath[2].x = width; clippath[2].y = height; clippath[2].next = &clippath[3]; + clippath[3].type = gfx_lineTo;clippath[3].x = 0; clippath[3].y = height; clippath[3].next = &clippath[4]; + clippath[4].type = gfx_lineTo;clippath[4].x = 0; clippath[4].y = 0; clippath[4].next = 0; + + if(!config_transparent) { + msg("<debug> drawing white background"); + dev->fill(dev, clippath, &white); + } + msg("<debug> startPage"); rgbdev->startPage(pageNum, state); gfxdev->startPage(pageNum, state); diff --git a/lib/pdf/FullBitmapOutputDev.h b/lib/pdf/FullBitmapOutputDev.h index e9ce21e..d7a8dc7 100644 --- a/lib/pdf/FullBitmapOutputDev.h +++ b/lib/pdf/FullBitmapOutputDev.h @@ -179,6 +179,8 @@ private: CharOutputDev*gfxdev; gfxdevice_t*dev; + + int config_transparent; }; #endif
--------------- SWFTools-common is a self-managed list. To subscribe/unsubscribe, or amend an existing subscription, please kindly point your favourite web browser at:<http://lists.nongnu.org/mailman/listinfo/swftools-common>
