From: Andreas L. Delmelle Date: Tue, 1 Feb 2011 20:03:46 +0000 (+0000) Subject: Bugzilla 50698: Changes after updating XGC JAR X-Git-Tag: fop-1_1rc1old~343 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3c839549f3deefeba13214cf950aee3b5b832523;p=xmlgraphics-fop.git Bugzilla 50698: Changes after updating XGC JAR git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1066182 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/pdf/PDFICCBasedColorSpace.java b/src/java/org/apache/fop/pdf/PDFICCBasedColorSpace.java index 7511bc20d..4d473bb7c 100644 --- a/src/java/org/apache/fop/pdf/PDFICCBasedColorSpace.java +++ b/src/java/org/apache/fop/pdf/PDFICCBasedColorSpace.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.io.InputStream; import org.apache.commons.io.IOUtils; +import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil; /** * Represents an ICCBased color space in PDF. @@ -134,21 +135,19 @@ public class PDFICCBasedColorSpace extends PDFObject implements PDFColorSpace { public static PDFICCStream setupsRGBColorProfile(PDFDocument pdfDoc) { ICC_Profile profile; PDFICCStream sRGBProfile = pdfDoc.getFactory().makePDFICCStream(); - synchronized (PDFICCBasedColorSpace.class) { - InputStream in = PDFDocument.class.getResourceAsStream("sRGB Color Space Profile.icm"); - if (in != null) { - try { - profile = ICC_Profile.getInstance(in); - } catch (IOException ioe) { - throw new RuntimeException( - "Unexpected IOException loading the sRGB profile: " + ioe.getMessage()); - } finally { - IOUtils.closeQuietly(in); - } - } else { - // Fallback: Use the sRGB profile from the JRE (about 140KB) - profile = ICC_Profile.getInstance(ColorSpace.CS_sRGB); + InputStream in = PDFDocument.class.getResourceAsStream("sRGB Color Space Profile.icm"); + if (in != null) { + try { + profile = ColorProfileUtil.getICC_Profile(in); + } catch (IOException ioe) { + throw new RuntimeException( + "Unexpected IOException loading the sRGB profile: " + ioe.getMessage()); + } finally { + IOUtils.closeQuietly(in); } + } else { + // Fallback: Use the sRGB profile from the JRE (about 140KB) + profile = ColorProfileUtil.getICC_Profile(ColorSpace.CS_sRGB); } sRGBProfile.setColorSpace(profile, null); return sRGBProfile; diff --git a/src/java/org/apache/fop/pdf/PDFResources.java b/src/java/org/apache/fop/pdf/PDFResources.java index 12eca75e4..99a42433c 100644 --- a/src/java/org/apache/fop/pdf/PDFResources.java +++ b/src/java/org/apache/fop/pdf/PDFResources.java @@ -25,12 +25,12 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; +import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil; import org.apache.fop.fonts.FontDescriptor; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.Typeface; import org.apache.fop.fonts.base14.Symbol; import org.apache.fop.fonts.base14.ZapfDingbats; -import org.apache.fop.util.ColorProfileUtil; /** * class representing a /Resources object. diff --git a/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java b/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java index 2130ef685..9e20886e0 100644 --- a/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java +++ b/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java @@ -25,6 +25,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.xmlgraphics.image.loader.Image; +import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil; import org.apache.fop.pdf.PDFColor; import org.apache.fop.pdf.PDFConformanceException; @@ -35,7 +36,6 @@ import org.apache.fop.pdf.PDFICCBasedColorSpace; import org.apache.fop.pdf.PDFICCStream; import org.apache.fop.pdf.PDFImage; import org.apache.fop.pdf.PDFReference; -import org.apache.fop.util.ColorProfileUtil; /** * Abstract PDFImage implementation for the PDF renderer. diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java b/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java index ae205a1e5..e63059472 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java @@ -35,6 +35,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.xmlgraphics.image.loader.util.ImageUtil; +import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil; import org.apache.xmlgraphics.xmp.Metadata; import org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter; import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema; @@ -64,7 +65,6 @@ import org.apache.fop.pdf.PDFReference; import org.apache.fop.pdf.PDFText; import org.apache.fop.pdf.PDFXMode; import org.apache.fop.render.pdf.extensions.PDFEmbeddedFileExtensionAttachment; -import org.apache.fop.util.ColorProfileUtil; /** * Utility class which enables all sorts of features that are not directly connected to the @@ -294,7 +294,7 @@ class PDFRenderingUtil implements PDFConfigurationConstants { in = new URL(src.getSystemId()).openStream(); } try { - profile = ICC_Profile.getInstance(in); + profile = ColorProfileUtil.getICC_Profile(in); } finally { IOUtils.closeQuietly(in); } diff --git a/src/java/org/apache/fop/util/ColorProfileUtil.java b/src/java/org/apache/fop/util/ColorProfileUtil.java index 35b6660dc..9ee34d2b6 100644 --- a/src/java/org/apache/fop/util/ColorProfileUtil.java +++ b/src/java/org/apache/fop/util/ColorProfileUtil.java @@ -19,13 +19,11 @@ package org.apache.fop.util; -import java.awt.color.ColorSpace; -import java.awt.color.ICC_ColorSpace; import java.awt.color.ICC_Profile; -import java.io.UnsupportedEncodingException; /** * Helper methods for handling color profiles. + * @deprecated use org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil directly */ public final class ColorProfileUtil { @@ -36,21 +34,11 @@ public final class ColorProfileUtil { * Returns the profile description of an ICC profile * @param profile the profile * @return the description + * @deprecated use org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil directly */ public static String getICCProfileDescription(ICC_Profile profile) { - byte[] data = profile.getData(ICC_Profile.icSigProfileDescriptionTag); - if (data == null) { - return null; - } else { - //Info on the data format: http://www.color.org/ICC-1_1998-09.PDF - int length = (data[8] << 3 * 8) | (data[9] << 2 * 8) | (data[10] << 8) | data[11]; - length--; //Remove trailing NUL character - try { - return new String(data, 12, length, "US-ASCII"); - } catch (UnsupportedEncodingException e) { - throw new UnsupportedOperationException("Incompatible VM"); - } - } + return org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil + .getICCProfileDescription(profile); } /** @@ -58,14 +46,10 @@ public final class ColorProfileUtil { * provided by the Java class library. * @param profile the color profile to check * @return true if it is the default sRGB profile + * @deprecated use org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil directly */ public static boolean isDefaultsRGB(ICC_Profile profile) { - ColorSpace sRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB); - ICC_Profile sRGBProfile = null; - if (sRGB instanceof ICC_ColorSpace) { - sRGBProfile = ((ICC_ColorSpace)sRGB).getProfile(); - } - return profile == sRGBProfile; + return org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil + .isDefaultsRGB(profile); } - } diff --git a/src/java/org/apache/fop/util/ColorSpaceCache.java b/src/java/org/apache/fop/util/ColorSpaceCache.java index 7b3f409e0..63d8746f7 100644 --- a/src/java/org/apache/fop/util/ColorSpaceCache.java +++ b/src/java/org/apache/fop/util/ColorSpaceCache.java @@ -31,6 +31,7 @@ import javax.xml.transform.stream.StreamSource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil; /** * Map with cached ICC based ColorSpace objects. @@ -40,7 +41,8 @@ public class ColorSpaceCache { private static Log log = LogFactory.getLog(ColorSpaceCache.class); private URIResolver resolver; - private Map colorSpaceMap = Collections.synchronizedMap(new java.util.HashMap()); + private Map colorSpaceMap + = Collections.synchronizedMap(new java.util.HashMap()); /** * Default constructor @@ -74,7 +76,7 @@ public class ColorSpaceCache { if (src != null && src instanceof StreamSource) { // FOP URI resolver found ICC profile - create ICC profile // from the Source - iccProfile = ICC_Profile.getInstance(((StreamSource) src) + iccProfile = ColorProfileUtil.getICC_Profile(((StreamSource) src) .getInputStream()); } else { // TODO - Would it make sense to fall back on VM ICC @@ -102,8 +104,7 @@ public class ColorSpaceCache { log.warn("Color profile '" + iccProfileSrc + "' not found."); } } else { - colorSpace = (ColorSpace)colorSpaceMap.get(base - + iccProfileSrc); + colorSpace = colorSpaceMap.get(base + iccProfileSrc); } return colorSpace; }