From 2da3ee78778bc943d241178fae2e79378ee6ebd9 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Tue, 28 Apr 2009 15:40:04 +0000 Subject: 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 --- .../org/apache/fop/afp/ptoca/PtocaBuilder.java | 46 ++++++++++++++++------ 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3