瀏覽代碼

Fix for a potential NPE when painting vector graphics with non-sRGB colors.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1074810 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-1_1rc1old
Jeremias Maerki 13 年之前
父節點
當前提交
aba70fb7a1

+ 5
- 1
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;

/**
@@ -34,6 +35,7 @@ public class PDFICCBasedColorSpace extends PDFObject implements PDFColorSpace {

private PDFICCStream iccStream;
private String explicitName;
private int numComponents;

/**
* Constructs a the ICCBased color space with an explicit name (ex. "DefaultRGB").
@@ -43,6 +45,7 @@ public class PDFICCBasedColorSpace extends PDFObject implements PDFColorSpace {
public PDFICCBasedColorSpace(String explicitName, PDFICCStream iccStream) {
this.explicitName = explicitName;
this.iccStream = iccStream;
this.numComponents = iccStream.getICCProfile().getNumComponents();
}

/**
@@ -60,7 +63,7 @@ public class PDFICCBasedColorSpace extends PDFObject implements PDFColorSpace {

/** {@inheritDoc} */
public int getNumComponents() {
return iccStream.getICCProfile().getNumComponents();
return this.numComponents;
}

/** {@inheritDoc} */
@@ -93,6 +96,7 @@ public class PDFICCBasedColorSpace extends PDFObject implements PDFColorSpace {
}

/** {@inheritDoc} */
@Override
protected String toPDFString() {
StringBuffer sb = new StringBuffer(64);
sb.append(getObjectID());

+ 8
- 1
src/java/org/apache/fop/pdf/PDFICCStream.java 查看文件

@@ -49,7 +49,11 @@ public class PDFICCStream extends PDFStream {
pdfColorSpace = alt;
}

/** @return the ICC profile */
/**
* Returns the associated ICC profile. Note that this will return null once the
* ICC stream has been written to the PDF file.
* @return the ICC profile (or null if the stream has already been written)
*/
public ICC_Profile getICCProfile() {
return this.cp;
}
@@ -59,6 +63,7 @@ public class PDFICCStream extends PDFStream {
* byte arrays around so much
* {@inheritDoc}
*/
@Override
protected int output(java.io.OutputStream stream)
throws java.io.IOException {
int length = super.output(stream);
@@ -67,11 +72,13 @@ public class PDFICCStream extends PDFStream {
}

/** {@inheritDoc} */
@Override
protected void outputRawStreamData(OutputStream out) throws IOException {
cp.write(out);
}

/** {@inheritDoc} */
@Override
protected void populateStreamDict(Object lengthEntry) {
put("N", cp.getNumComponents());
if (pdfColorSpace != null) {

Loading…
取消
儲存