001: /**
002: * Copyright (c) 2004, www.pdfbox.org
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions are met:
007: *
008: * 1. Redistributions of source code must retain the above copyright notice,
009: * this list of conditions and the following disclaimer.
010: * 2. Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: * 3. Neither the name of pdfbox; nor the names of its
014: * contributors may be used to endorse or promote products derived from this
015: * software without specific prior written permission.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
018: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
019: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
020: * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
021: * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
022: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
023: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
024: * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
026: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027: *
028: * http://www.pdfbox.org
029: *
030: */package org.pdfbox.pdmodel.graphics.color;
031:
032: import java.awt.color.ColorSpace;
033: import java.awt.color.ICC_ColorSpace;
034: import java.awt.color.ICC_Profile;
035: import java.awt.image.ColorModel;
036:
037: import java.io.InputStream;
038: import java.io.IOException;
039:
040: import org.pdfbox.util.ResourceLoader;
041:
042: /**
043: * This class represents a CMYK color space.
044: *
045: * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
046: * @version $Revision: 1.6 $
047: */
048: public class PDDeviceCMYK extends PDColorSpace {
049: /**
050: * The single instance of this class.
051: */
052: public static final PDDeviceCMYK INSTANCE = new PDDeviceCMYK();
053:
054: /**
055: * The name of this color space.
056: */
057: public static final String NAME = "DeviceCMYK";
058:
059: /**
060: * The abbreviated name of this color space.
061: */
062: public static final String ABBREVIATED_NAME = "CMYK";
063:
064: private ColorSpace cSpace = null;
065:
066: private PDDeviceCMYK() {
067:
068: }
069:
070: /**
071: * This will return the name of the color space.
072: *
073: * @return The name of the color space.
074: */
075: public String getName() {
076: return NAME;
077: }
078:
079: /**
080: * This will get the number of components that this color space is made up of.
081: *
082: * @return The number of components in this color space.
083: *
084: * @throws IOException If there is an error getting the number of color components.
085: */
086: public int getNumberOfComponents() throws IOException {
087: return 4;
088: }
089:
090: /**
091: * Create a Java colorspace for this colorspace.
092: *
093: * @return A color space that can be used for Java AWT operations.
094: *
095: * @throws IOException If there is an error creating the color space.
096: */
097: public ColorSpace createColorSpace() throws IOException {
098: if (cSpace == null) {
099: InputStream profile = null;
100: try {
101: profile = ResourceLoader
102: .loadResource("Resources/colorspace-profiles/CMYK.pf");
103: ICC_Profile iccProfile = ICC_Profile
104: .getInstance(profile);
105: cSpace = new ICC_ColorSpace(iccProfile);
106: } finally {
107: if (profile != null) {
108: profile.close();
109: }
110: }
111: }
112: return cSpace;
113: }
114:
115: /**
116: * Create a Java color model for this colorspace.
117: *
118: * @param bpc The number of bits per component.
119: *
120: * @return A color model that can be used for Java AWT operations.
121: *
122: * @throws IOException If there is an error creating the color model.
123: */
124: public ColorModel createColorModel(int bpc) throws IOException {
125: throw new IOException("Not implemented");
126: }
127: }
|