X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fpdf%2FBitmapOutputDev.cc;h=1a735e31a5d2fd385bd91ce11b858cacf2b3475c;hp=32acd80ca96400170a5964d42f66bd07dae92b4f;hb=944d0b42a196bd412c12c6c06fd0e4f301d4a1c7;hpb=c10fb05b68fa1c717ef7d62d84bfb29008d41c33 diff --git a/lib/pdf/BitmapOutputDev.cc b/lib/pdf/BitmapOutputDev.cc index 32acd80..1a735e3 100644 --- a/lib/pdf/BitmapOutputDev.cc +++ b/lib/pdf/BitmapOutputDev.cc @@ -75,7 +75,7 @@ BitmapOutputDev::BitmapOutputDev(InfoOutputDev*info, PDFDoc*doc) this->clip1dev->startDoc(this->xref); this->gfxoutput = (gfxdevice_t*)malloc(sizeof(gfxdevice_t)); - gfxdevice_record_init(this->gfxoutput); + gfxdevice_record_init(this->gfxoutput, 0); this->gfxdev->setDevice(this->gfxoutput); @@ -159,6 +159,8 @@ void BitmapOutputDev::setPageMap(int*page2page, int num_pages) this->gfxdev->setPageMap(page2page, num_pages); } +void writeBitmap(SplashBitmap*bitmap, char*filename); + void BitmapOutputDev::flushBitmap() { int width = rgbdev->getBitmapWidth(); @@ -168,14 +170,22 @@ void BitmapOutputDev::flushBitmap() msg(" 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 = get_bitmap_bboxes((unsigned char*)alpha, width, height); ibbox_t*b; + for(b=boxes;b;b=b->next) { int xmin = b->xmin; int ymin = b->ymin; @@ -204,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+xmin)&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]; + } } } }