aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2009-04-28 15:40:04 +0000
committerVincent Hennebert <vhennebert@apache.org>2009-04-28 15:40:04 +0000
commit2da3ee78778bc943d241178fae2e79378ee6ebd9 (patch)
treef60f921e9a4579edf08699e665f77623a3a72c76 /src
parent567829784c0b4a7844299fe708f254b89913a305 (diff)
downloadxmlgraphics-fop-2da3ee78778bc943d241178fae2e79378ee6ebd9.tar.gz
xmlgraphics-fop-2da3ee78778bc943d241178fae2e79378ee6ebd9.zip
Added support for CMYK colors in PTOCA
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@769437 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/afp/ptoca/PtocaBuilder.java46
1 files changed, 33 insertions, 13 deletions
diff --git a/src/java/org/apache/fop/afp/ptoca/PtocaBuilder.java b/src/java/org/apache/fop/afp/ptoca/PtocaBuilder.java
index 3a6507252..40adb5ed8 100644
--- a/src/java/org/apache/fop/afp/ptoca/PtocaBuilder.java
+++ b/src/java/org/apache/fop/afp/ptoca/PtocaBuilder.java
@@ -20,6 +20,7 @@
package org.apache.fop.afp.ptoca;
import java.awt.Color;
+import java.awt.color.ColorSpace;
import java.io.IOException;
import java.io.OutputStream;
@@ -314,19 +315,38 @@ public abstract class PtocaBuilder implements PtocaConstants {
return;
}
newControlSequence();
- writeByte(0x00); // Reserved; must be zero
- writeByte(0x01); // Color space - 0x01 = RGB
- writeByte(0x00); // Reserved; must be zero
- writeByte(0x00); // Reserved; must be zero
- writeByte(0x00); // Reserved; must be zero
- writeByte(0x00); // Reserved; must be zero
- writeByte(8); // Number of bits in component 1
- writeByte(8); // Number of bits in component 2
- writeByte(8); // Number of bits in component 3
- writeByte(0); // Number of bits in component 4
- writeByte(col.getRed()); // Red intensity
- writeByte(col.getGreen()); // Green intensity
- writeByte(col.getBlue()); // Blue intensity
+ if (col.getColorSpace().getType() == ColorSpace.TYPE_CMYK) {
+ writeByte(0x00); // Reserved; must be zero
+ writeByte(0x04); // Color space - 0x04 = CMYK
+ writeByte(0x00); // Reserved; must be zero
+ writeByte(0x00); // Reserved; must be zero
+ writeByte(0x00); // Reserved; must be zero
+ writeByte(0x00); // Reserved; must be zero
+ writeByte(8); // Number of bits in component 1
+ writeByte(8); // Number of bits in component 2
+ writeByte(8); // Number of bits in component 3
+ writeByte(8); // Number of bits in component 4
+ float[] comps = col.getColorComponents(null);
+ assert comps.length == 4;
+ for (int i = 0; i < 4; i++) {
+ int component = Math.round(comps[i] * 256);
+ writeByte(component);
+ }
+ } else {
+ writeByte(0x00); // Reserved; must be zero
+ writeByte(0x01); // Color space - 0x01 = RGB
+ writeByte(0x00); // Reserved; must be zero
+ writeByte(0x00); // Reserved; must be zero
+ writeByte(0x00); // Reserved; must be zero
+ writeByte(0x00); // Reserved; must be zero
+ writeByte(8); // Number of bits in component 1
+ writeByte(8); // Number of bits in component 2
+ writeByte(8); // Number of bits in component 3
+ writeByte(0); // Number of bits in component 4
+ writeByte(col.getRed()); // Red intensity
+ writeByte(col.getGreen()); // Green intensity
+ writeByte(col.getBlue()); // Blue intensity
+ }
commit(chained(SEC));
this.currentColor = col;
}