KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lowagie > text > pdf > PdfICCBased


1 /*
2  *
3  * The contents of this file are subject to the Mozilla Public License Version 1.1
4  * (the "License"); you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS" basis,
8  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9  * for the specific language governing rights and limitations under the License.
10  *
11  * The Original Code is 'iText, a free JAVA-PDF library'.
12  *
13  * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
14  * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
15  * All Rights Reserved.
16  * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
17  * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
18  *
19  * Contributor(s): all the names of the contributors are added in the source code
20  * where applicable.
21  *
22  * Alternatively, the contents of this file may be used under the terms of the
23  * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
24  * provisions of LGPL are applicable instead of those above. If you wish to
25  * allow use of your version of this file only under the terms of the LGPL
26  * License and not to allow others to use your version of this file under
27  * the MPL, indicate your decision by deleting the provisions above and
28  * replace them with the notice and other provisions required by the LGPL.
29  * If you do not delete the provisions above, a recipient may use your version
30  * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
31  *
32  * This library is free software; you can redistribute it and/or modify it
33  * under the terms of the MPL as stated above or under the terms of the GNU
34  * Library General Public License as published by the Free Software Foundation;
35  * either version 2 of the License, or any later version.
36  *
37  * This library is distributed in the hope that it will be useful, but WITHOUT
38  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
39  * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
40  * details.
41  *
42  * If you didn't download this code from the following link, you should check if
43  * you aren't using an obsolete version:
44  * http://www.lowagie.com/iText/
45  */

46 package com.lowagie.text.pdf;
47
48 import java.awt.color.ICC_Profile JavaDoc;
49
50 import com.lowagie.text.ExceptionConverter;
51
52 /**
53  * A <CODE>PdfICCBased</CODE> defines a ColorSpace
54  *
55  * @see PdfStream
56  */

57
58 class PdfICCBased extends PdfStream {
59     
60     protected int NumberOfComponents;
61     
62     PdfICCBased(ICC_Profile JavaDoc profile) {
63         super();
64         try {
65             NumberOfComponents = profile.getNumComponents();
66             switch (NumberOfComponents) {
67                 case 1:
68                     put(PdfName.ALTERNATE, PdfName.DEVICEGRAY);
69                     break;
70                 case 3:
71                     put(PdfName.ALTERNATE, PdfName.DEVICERGB);
72                     break;
73                 case 4:
74                     put(PdfName.ALTERNATE, PdfName.DEVICECMYK);
75                     break;
76                 default:
77                     throw new PdfException(NumberOfComponents + " component(s) is not supported in PDF1.4");
78             }
79             put(PdfName.N, new PdfNumber(NumberOfComponents));
80             bytes = profile.getData();
81             flateCompress();
82         } catch (Exception JavaDoc e) {
83             throw new ExceptionConverter(e);
84         }
85     }
86 }
87
Popular Tags