123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- /*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
- package org.apache.fop.pdf;
-
- public class PDFColorSpace {
- private boolean hasICCProfile;
- private byte[] iccProfile;
- private int numComponents;
-
- // Ok... so I had some grand purpose for this, but I can't recall.
- // I'm just writing it
-
- public static int DEVICE_UNKNOWN = -1;
- public static int DEVICE_GRAY = 1;
- // what's the *official* spelling?
- // public static int DEVICE_GREY = 1;
- public static int DEVICE_RGB = 2;
- public static int DEVICE_CMYK = 3;
-
- // Are there any others?
-
- protected int currentColorSpace = DEVICE_UNKNOWN;
-
- public PDFColorSpace(int theColorSpace) {
- this.currentColorSpace = theColorSpace;
- hasICCProfile = false;
- numComponents = calculateNumComponents();
- }
-
- private int calculateNumComponents() {
- if (currentColorSpace == DEVICE_GRAY) {
- return 1;
- } else if (currentColorSpace == DEVICE_RGB) {
- return 3;
- } else if (currentColorSpace == DEVICE_CMYK) {
- return 4;
- } else {
- return 0;
- }
- }
-
- public void setColorSpace(int theColorSpace) {
- this.currentColorSpace = theColorSpace;
- numComponents = calculateNumComponents();
- }
-
- public boolean hasICCProfile() {
- return hasICCProfile;
- }
-
- public byte[] getICCProfile() {
- if (hasICCProfile)
- return iccProfile;
- else
- return new byte[0];
- }
-
- public void setICCProfile(byte[] iccProfile) {
- this.iccProfile = iccProfile;
- hasICCProfile = true;
- }
-
- public int getColorSpace() {
- return (this.currentColorSpace);
- }
-
- public int getNumComponents() {
- return numComponents;
- }
-
- public String getColorSpacePDFString() {
- // shouldn't this be a select-case? I can never remember
- // the syntax for that.
- if (this.currentColorSpace == this.DEVICE_RGB) {
- return ("DeviceRGB");
- } else if (this.currentColorSpace == this.DEVICE_CMYK) {
- return ("DeviceCMYK");
- } else if (this.currentColorSpace == this.DEVICE_GRAY) {
- return ("DeviceGray");
- } else { // unknown... Error. Tell them it's RGB and hope they don't notice.
- return ("DeviceRGB");
- }
- }
-
- }
|