X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fpdf%2FBitmapOutputDev.cc;h=6eaea6bcb461ff4c9b68c82464c85a37a25f7113;hp=2889e5eaf03d83dbd22215e247b0f8e544727957;hb=b43d07ef45012438211d2ed4b588e77b73a1994c;hpb=87d83a44189289390d90638357b508f461c4895b diff --git a/lib/pdf/BitmapOutputDev.cc b/lib/pdf/BitmapOutputDev.cc index 2889e5e..6eaea6b 100644 --- a/lib/pdf/BitmapOutputDev.cc +++ b/lib/pdf/BitmapOutputDev.cc @@ -30,6 +30,7 @@ #include "../png.h" #include "../devices/record.h" #include "../types.h" +#include "bbox.h" #define UNKNOWN_BOUNDING_BOX 0,0,0,0 @@ -158,63 +159,7 @@ void BitmapOutputDev::setPageMap(int*page2page, int num_pages) this->gfxdev->setPageMap(page2page, num_pages); } -typedef struct _ibbox { - int xmin,ymin,xmax,ymax; - struct _ibbox*next; -} ibbox_t; - -static ibbox_t* ibbox_new(int x1, int y1, int x2, int y2) -{ - ibbox_t*b = (ibbox_t*)rfx_calloc(sizeof(ibbox_t)); - b->xmin = x1; - b->ymin = y1; - b->xmax = x2; - b->ymax = y2; - return b; -} - -static void ibbox_destroy(ibbox_t*b) -{ - while(b) { - ibbox_t*next = b->next; - free(b); - b = next; - } -} - -static ibbox_t*getBitmapBBoxes(Guchar*alpha, int width, int height) -{ - int ymin = -1; - int ymax = -1; - int xmin = width; - int xmax = 0; - - int x,y; - for(y=0;yxmax) xmax = right; - } - } - ibbox_t* bbox = 0; - if(xmin sizeof(SplashColor)!=3"); return; } + + /*static int counter=0; + if(!counter) { + writeBitmap(rgbdev->getBitmap(), "test.png"); + } counter++;*/ SplashColorPtr rgb = rgbbitmap->getDataPtr(); Guchar*alpha = rgbbitmap->getAlphaPtr(); - Guchar*alpha2 = boolpolybitmap->getAlphaPtr(); + + Guchar*alpha2 = boolpolybitmap->getDataPtr(); + int width8 = (boolpolybitmap->getWidth()+7)/8; - ibbox_t* boxes = getBitmapBBoxes(alpha, width, height); + ibbox_t* boxes = get_bitmap_bboxes((unsigned char*)alpha, width, height); ibbox_t*b; - for(b=boxes;boxes;boxes=boxes->next) { + + for(b=boxes;b;b=b->next) { int xmin = b->xmin; int ymin = b->ymin; int xmax = b->xmax; @@ -261,7 +214,7 @@ void BitmapOutputDev::flushBitmap() SplashColorPtr in=&rgb[((y+ymin)*width+xmin)*sizeof(SplashColor)]; gfxcolor_t*out = &img->data[y*rangex]; Guchar*ain = &alpha[(y+ymin)*width+xmin]; - Guchar*ain2 = &alpha2[(y+ymin)*width+xmin]; + Guchar*ain2 = &alpha2[(y+ymin)*width8]; if(this->emptypage) { for(x=0;x>(x&7)))) { + /* cut away pixels that we don't remember drawing (i.e., that are + not in the monochrome bitmap. Prevents some "hairlines" showing + up to the left and right of bitmaps */ out[x].r = 0;out[x].g = 0;out[x].b = 0;out[x].a = 0; - } else */ - - /* according to endPage()/compositeBackground() in xpdf/SplashOutputDev.cc, we - have to premultiply alpha (mix background and pixel according to the alpha channel). - */ - out[x].r = (in[x*3+0]*ain[x])/255; - out[x].g = (in[x*3+1]*ain[x])/255; - out[x].b = (in[x*3+2]*ain[x])/255; - out[x].a = ain[x]; + } else { + /* according to endPage()/compositeBackground() in xpdf/SplashOutputDev.cc, we + have to premultiply alpha (mix background and pixel according to the alpha channel). + */ + out[x].r = (in[x*3+0]*ain[x])/255; + out[x].g = (in[x*3+1]*ain[x])/255; + out[x].b = (in[x*3+2]*ain[x])/255; + out[x].a = ain[x]; + } } } }