Author: tilman
Date: Mon Aug 17 18:53:41 2026
New Revision: 1937183

Log:
PDFBOX-6077: go back to assigning alpha instead of combining, but only if not 
transparent; optimize

Modified:
   
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java

Modified: 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
==============================================================================
--- 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
        Mon Aug 17 18:53:37 2026        (r1937182)
+++ 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
        Mon Aug 17 18:53:41 2026        (r1937183)
@@ -1329,15 +1329,17 @@ public class PageDrawer extends PDFGraph
                 {
                     for (int x = 0; x < w; x++)
                     {
-                        alphaPixel = alpha.getPixel(x, y, alphaPixel);
                         rasterPixel = raster.getPixel(x, y, rasterPixel);
-                        // PDFBOX-6077 (for the file in PDFBOX-5403):
-                        // combine with the paint's own alpha instead of
-                        // overwriting it, so gaps the paint never drew into 
(e.g. between
-                        // tiles of a tiling pattern) stay transparent instead 
of turning
-                        // into opaque black.
-                        rasterPixel[3] = rasterPixel[3] * alphaPixel[0] / 255;
-                        raster.setPixel(x, y, rasterPixel);
+                        // PDFBOX-6077 + for the file in PDFBOX-5403:
+                        // don't overwrite the paint when transparent,
+                        // so gaps the paint never drew into (e.g. between 
tiles of a tiling pattern)
+                        // stay transparent instead of turning into opaque 
black.
+                        if (rasterPixel[3] != 0)
+                        {
+                            alphaPixel = alpha.getPixel(x, y, alphaPixel);
+                            rasterPixel[3] = alphaPixel[0];
+                            raster.setPixel(x, y, rasterPixel);
+                        }
                     }
                 }
 

Reply via email to