From 97771c4e93dc1032bc7e793a0aa18f5137f2f2b4 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Wed, 17 Sep 2008 16:41:14 +0000 Subject: [PATCH] Bugzilla #45795: PDF Output: Added support for handling 16-bit alpha channel. They are currently converted to 8 bits. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@696365 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/pdf/AlphaRasterImage.java | 15 +++++++++++++++ status.xml | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/src/java/org/apache/fop/pdf/AlphaRasterImage.java b/src/java/org/apache/fop/pdf/AlphaRasterImage.java index ae39cadb7..bd31148be 100644 --- a/src/java/org/apache/fop/pdf/AlphaRasterImage.java +++ b/src/java/org/apache/fop/pdf/AlphaRasterImage.java @@ -48,6 +48,9 @@ public class AlphaRasterImage implements PDFImage { */ public AlphaRasterImage(String k, Raster alpha) { this.key = k; + //Enable the commented line below if 16-bit alpha channels are desired. + //Otherwise, we compress the alpha channel to 8 bit which should be sufficient. + //this.bitsPerComponent = alpha.getSampleModel().getSampleSize(0); this.bitsPerComponent = 8; this.colorSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_GRAY); if (alpha == null) { @@ -148,6 +151,18 @@ public class AlphaRasterImage implements PDFImage { alpha.getDataElements(0, y, w, 1, line); out.write(line); } + } else if (dataType == DataBuffer.TYPE_USHORT) { + short[] sline = new short[nbands * w]; + byte[] line = new byte[nbands * w]; + for (int y = 0; y < h; y++) { + alpha.getDataElements(0, y, w, 1, sline); + for (int i = 0; i < w; i++) { + //this compresses a 16-bit alpha channel to 8 bits! + //we probably don't ever need a 16-bit channel + line[i] = (byte)(sline[i] >> 8); + } + out.write(line); + } } else if (dataType == DataBuffer.TYPE_INT) { //Is there an better way to get a 8bit raster from a TYPE_INT raster? int shift = 24; diff --git a/status.xml b/status.xml index 637445cfa..50fc66b0a 100644 --- a/status.xml +++ b/status.xml @@ -53,6 +53,10 @@ + + PDF Output: Added support for handling 16-bit alpha channel. They are currently + converted to 8 bits. + PDF Output: Made sure the XMP Metadata stream is never compressed. -- 2.39.5