diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-10-24 11:47:07 +0200 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-10-24 11:47:42 +0200 |
commit | 0a291a645e91294553c3171b9291fbf60ee3fae2 (patch) | |
tree | a53865eb7b630f1656d5638ffb1ce29c66b36921 | |
parent | b14be6946454595f9a890e4015622a565ab3caa7 (diff) | |
download | pdf-as-4-0a291a645e91294553c3171b9291fbf60ee3fae2.tar.gz pdf-as-4-0a291a645e91294553c3171b9291fbf60ee3fae2.tar.bz2 pdf-as-4-0a291a645e91294553c3171b9291fbf60ee3fae2.zip |
Remove support for Alpha Images
-rw-r--r-- | pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/ImageUtils.java | 16 | ||||
-rw-r--r-- | pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java | 4 |
2 files changed, 14 insertions, 6 deletions
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/ImageUtils.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/ImageUtils.java index 5dd0f636..b426e1ce 100644 --- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/ImageUtils.java +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/ImageUtils.java @@ -23,11 +23,9 @@ ******************************************************************************/ package at.gv.egiz.pdfas.common.utils; -import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; -import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.IndexColorModel; @@ -53,7 +51,7 @@ public class ImageUtils { .getLogger(ImageUtils.class); public static BufferedImage removeAlphaChannel(BufferedImage src) { - if (src.getColorModel().hasAlpha()) + /*if (src.getColorModel().hasAlpha()) { // extract the alpha information // WritableRaster alphaRaster = src. @@ -69,7 +67,17 @@ public class ImageUtils { g.dispose(); return image; } - return src; + return src;*/ + + BufferedImage rgbImage = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_3BYTE_BGR); + for (int x = 0; x < src.getWidth(); ++x) + { + for (int y = 0; y < src.getHeight(); ++y) + { + rgbImage.setRGB(x, y, src.getRGB(x, y) & 0xFFFFFF); + } + } + return rgbImage; } public static BufferedImage convertRGBAToIndexed(BufferedImage src) { diff --git a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java index f5776c0a..2b587d72 100644 --- a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java +++ b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java @@ -596,10 +596,10 @@ public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder { logger.debug("Scaling image to: " + iwidth + " x " + iheight); - if (img.getAlphaRaster() == null - && img.getColorModel().hasAlpha()) { + if (img.getColorModel().hasAlpha()) { img = ImageUtils.removeAlphaChannel(img); } + //img = ImageUtils.convertRGBAToIndexed(img); PDXObjectImage pdImage = new PDPixelMap(template, img); |