From acb0ddfd23901382fa23b508905a383a9af9f1e9 Mon Sep 17 00:00:00 2001 From: obo Date: Tue, 5 Sep 2023 10:13:41 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-103847=20=E5=AF=BC=E5=87=BA=E5=90=8E?= =?UTF-8?q?=E8=93=9D=E8=89=B2=E5=9B=BE=E7=89=87=E4=B8=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/third/com/lowagie/text/Image.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/fine-itext-old/src/main/java/com/fr/third/com/lowagie/text/Image.java b/fine-itext-old/src/main/java/com/fr/third/com/lowagie/text/Image.java index b583af20a..515160b54 100644 --- a/fine-itext-old/src/main/java/com/fr/third/com/lowagie/text/Image.java +++ b/fine-itext-old/src/main/java/com/fr/third/com/lowagie/text/Image.java @@ -757,8 +757,25 @@ public abstract class Image extends Rectangle { transparency[0] = transparency[1] = (transparentPixel >> 16) & 0xff; transparency[2] = transparency[3] = (transparentPixel >> 8) & 0xff; transparency[4] = transparency[5] = transparentPixel & 0xff; + // Added by Michael Klink + // Check whether this value for transparent pixels + // has already been used for a non-transparent one + // before this position + for (int prevPixel = 0; prevPixel < j; prevPixel++) { + if ((pixels[prevPixel] & 0xffffff) == transparentPixel) { + // found a prior use of the transparentPixel color + // and, therefore, cannot make use of this color + // for transparency; we could still use an image + // mask but for simplicity let's use a soft mask + // which already is implemented here + shades = true; + break; + } + } } - } else if ((pixels[j] & 0xffffff) != transparentPixel) { + } else if (((pixels[j] & 0xffffff) != transparentPixel) && (alpha == 0)) { + shades = true; + } else if (((pixels[j] & 0xffffff) == transparentPixel) && (alpha != 0)) { shades = true; } }