don't use alpha channel in bitmap
authorkramm <kramm>
Wed, 19 Mar 2008 21:50:36 +0000 (21:50 +0000)
committerkramm <kramm>
Wed, 19 Mar 2008 21:50:36 +0000 (21:50 +0000)
lib/pdf/FullBitmapOutputDev.cc

index d35956d..f19fd25 100644 (file)
@@ -167,13 +167,11 @@ void FullBitmapOutputDev::flushBitmap()
        gfxcolor_t*out = &img->data[y*rangex];
        Guchar*ain = &alpha[(y+ymin)*width+xmin];
        for(x=0;x<rangex;x++) {
-           /* 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];
+           // blend against a white background
+           out[x].r = (in[x*3+0]*ain[x])/255 + 255-ain[x];
+           out[x].g = (in[x*3+1]*ain[x])/255 + 255-ain[x];
+           out[x].b = (in[x*3+2]*ain[x])/255 + 255-ain[x];
+           out[x].a = 255;//ain[x];
        }
     }
     /* transform bitmap rectangle to "device space" */
@@ -192,9 +190,6 @@ void FullBitmapOutputDev::flushBitmap()
     dev->fillbitmap(dev, line, img, &m, 0);
     gfxline_free(line);
 
-    memset(rgbdev->getBitmap()->getAlphaPtr(), 0, rgbdev->getBitmap()->getWidth()*rgbdev->getBitmap()->getHeight());
-    memset(rgbdev->getBitmap()->getDataPtr(), 0, rgbdev->getBitmap()->getRowSize()*rgbdev->getBitmap()->getHeight());
-
     free(img->data);img->data=0;free(img);img=0;
 }