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.
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;
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.
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;
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.
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;
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
in = new URL(src.getSystemId()).openStream();
}
try {
- profile = ICC_Profile.getInstance(in);
+ profile = ColorProfileUtil.getICC_Profile(in);
} finally {
IOUtils.closeQuietly(in);
}
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 {
* 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);
}
/**
* 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);
}
-
}
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.
private static Log log = LogFactory.getLog(ColorSpaceCache.class);
private URIResolver resolver;
- private Map colorSpaceMap = Collections.synchronizedMap(new java.util.HashMap());
+ private Map<String, ColorSpace> colorSpaceMap
+ = Collections.synchronizedMap(new java.util.HashMap<String, ColorSpace>());
/**
* Default constructor
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
log.warn("Color profile '" + iccProfileSrc + "' not found.");
}
} else {
- colorSpace = (ColorSpace)colorSpaceMap.get(base
- + iccProfileSrc);
+ colorSpace = colorSpaceMap.get(base + iccProfileSrc);
}
return colorSpace;
}