Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 3.0
-
Fix Version/s: 4.0 - Beta, 4.0
-
Component/s: Core/Parsing
-
Labels:None
-
Environment:java version "1.6.0_10"
linux
Description
When viewing some CMYK pdf files the color seems wrong (in my case black instead of red).
The reason for this seems to be that not all CMYK values are provided (in my case only MYK values). This can be fixed by applying the following patch
File: ./src/org/icepdf/core/pobjects/graphics/DeviceN.java
public Color getColor(float[] f) {
if (func == null) {
if (alternate.getNumComponents() > f.length) {
float[] ftmp = new float[alternate.getNumComponents()];
for (int index = 0; index < f.length && index < names.size(); index++) {
if (names.get(index).equals("Cyan")) {
ftmp[0] = f[index];
}
if (names.get(index).equals("Magenta")) {
ftmp[1] = f[index];
}
if (names.get(index).equals("Yellow")) {
ftmp[2] = f[index];
}
if (names.get(index).equals("Black")) {
ftmp[3] = f[index];
}
}
f = ftmp;
}
float y[] = new float[alternate.getNumComponents()];
for (int i = 0; i < Math.min(y.length, f.length); i++) {
y[i] = f[i];
}
return alternate.getColor(y);
}
float y[] = func.calculate(f);
if (colorspaces[0] != null) {
return colorspaces[0].getColor(reverse(y));
}
return alternate.getColor(reverse(y));
}
The reason for this seems to be that not all CMYK values are provided (in my case only MYK values). This can be fixed by applying the following patch
File: ./src/org/icepdf/core/pobjects/graphics/DeviceN.java
public Color getColor(float[] f) {
if (func == null) {
if (alternate.getNumComponents() > f.length) {
float[] ftmp = new float[alternate.getNumComponents()];
for (int index = 0; index < f.length && index < names.size(); index++) {
if (names.get(index).equals("Cyan")) {
ftmp[0] = f[index];
}
if (names.get(index).equals("Magenta")) {
ftmp[1] = f[index];
}
if (names.get(index).equals("Yellow")) {
ftmp[2] = f[index];
}
if (names.get(index).equals("Black")) {
ftmp[3] = f[index];
}
}
f = ftmp;
}
float y[] = new float[alternate.getNumComponents()];
for (int i = 0; i < Math.min(y.length, f.length); i++) {
y[i] = f[i];
}
return alternate.getColor(y);
}
float y[] = func.calculate(f);
if (colorspaces[0] != null) {
return colorspaces[0].getColor(reverse(y));
}
return alternate.getColor(reverse(y));
}
This file shows the wrong colors when opening in the unpatched 3.0 version