You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2026/08/18 08:32:00 UTC
svn commit: r1937200 - pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering
Author: tilman
Date: Tue Aug 18 08:32:00 2026
New Revision: 1937200
Log:
PDFBOX-6077: assign alpha instead of combining, but only if not transparent; optimize; add comment
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 Tue Aug 18 08:31:56 2026 (r1937199)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java Tue Aug 18 08:32:00 2026 (r1937200)
@@ -1337,6 +1337,8 @@ public class PageDrawer extends PDFGraph
if (rasterPixel[3] != 0)
{
alphaPixel = alpha.getPixel(x, y, alphaPixel);
+ // assign alpha; it's also possible to combine but the visual
+ // difference is currently minimal (see code of 16.8.2026)
rasterPixel[3] = alphaPixel[0];
raster.setPixel(x, y, rasterPixel);
}
@@ -1477,34 +1479,37 @@ public class PageDrawer extends PDFGraph
int maskX = (int) Math.floor(point.getX() - origin.getX());
int maskY = (int) Math.floor(point.getY() - origin.getY());
- int alphaScale;
- if (maskX >= 0 && maskY >= 0 && maskX < maskRaster.getWidth() && maskY < maskRaster.getHeight())
+ rasterPixel = raster.getPixel(x, y, rasterPixel);
+ if (rasterPixel[3] != 0)
{
- maskRaster.getPixel(maskX, maskY, gray);
- if (transferFunction != null)
+ int alphaScale;
+ if (maskX >= 0 && maskY >= 0 && maskX < maskRaster.getWidth() && maskY < maskRaster.getHeight())
{
- Float f = map[gray[0]];
- if (f == null)
+ maskRaster.getPixel(maskX, maskY, gray);
+ if (transferFunction != null)
+ {
+ Float f = map[gray[0]];
+ if (f == null)
+ {
+ input[0] = gray[0] / 255f;
+ f = transferFunction.eval(input)[0];
+ map[gray[0]] = f;
+ }
+ alphaScale = Math.round(255 * f);
+ }
+ else
{
- input[0] = gray[0] / 255f;
- f = transferFunction.eval(input)[0];
- map[gray[0]] = f;
+ alphaScale = gray[0];
}
- alphaScale = Math.round(255 * f);
}
else
{
- alphaScale = gray[0];
+ alphaScale = backdropColorValue;
}
- }
- else
- {
- alphaScale = backdropColorValue;
- }
- rasterPixel = raster.getPixel(x, y, rasterPixel);
- rasterPixel[3] = rasterPixel[3] * alphaScale / 255;
- raster.setPixel(x, y, rasterPixel);
+ rasterPixel[3] = alphaScale;
+ raster.setPixel(x, y, rasterPixel);
+ }
}
}
}