1 51 package org.apache.fop.datatypes; 52 53 public class ColorSpace { 54 private boolean hasICCProfile; 55 private byte[] iccProfile; 56 private int numComponents; 57 58 61 public static final int DEVICE_UNKNOWN = -1; 62 public static final int DEVICE_GRAY = 1; 63 public static final int DEVICE_RGB = 2; 66 public static final int DEVICE_CMYK = 3; 67 68 69 71 protected int currentColorSpace = -1; 72 73 public ColorSpace(int theColorSpace) { 74 this.currentColorSpace = theColorSpace; 75 hasICCProfile = false; 76 numComponents = calculateNumComponents(); 77 } 78 79 private int calculateNumComponents() { 80 if (currentColorSpace == DEVICE_GRAY) 81 return 1; 82 else if (currentColorSpace == DEVICE_RGB) 83 return 3; 84 else if (currentColorSpace == DEVICE_CMYK) 85 return 4; 86 else 87 return 0; 88 } 89 90 public void setColorSpace(int theColorSpace) { 91 this.currentColorSpace = theColorSpace; 92 numComponents = calculateNumComponents(); 93 } 94 95 public boolean hasICCProfile() { 96 return hasICCProfile; 97 } 98 99 public byte[] getICCProfile() { 100 if (hasICCProfile) 101 return iccProfile; 102 else 103 return new byte[0]; 104 } 105 106 public void setICCProfile(byte[] iccProfile) { 107 this.iccProfile = iccProfile; 108 hasICCProfile = true; 109 } 110 111 public int getColorSpace() { 112 return (this.currentColorSpace); 113 } 114 115 public int getNumComponents() { 116 return numComponents; 117 } 118 119 public String getColorSpacePDFString() { 121 122 if (this.currentColorSpace == this.DEVICE_RGB) { 125 return ("DeviceRGB"); 126 } else if (this.currentColorSpace == this.DEVICE_CMYK) { 127 return ("DeviceCMYK"); 128 } else if (this.currentColorSpace == this.DEVICE_GRAY) { 129 return ("DeviceGray"); 130 } else { return ("DeviceRGB"); 132 } 133 } 134 135 } 136 | Popular Tags |