KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > stefanochizzolini > clown > documents > contents > xObjects > ImageXObject


1 /*
2   Copyright 2006 Stefano Chizzolini. http://clown.stefanochizzolini.it
3
4   Contributors:
5     * Stefano Chizzolini (original code developer, info@stefanochizzolini.it):
6       contributed code is Copyright 2006 by Stefano Chizzolini.
7
8   This file should be part of the source code distribution of "PDF Clown library"
9   (the Program): see the accompanying README files for more info.
10
11   This Program is free software; you can redistribute it and/or modify it under
12   the terms of the GNU General Public License as published by the Free Software
13   Foundation; either version 2 of the License, or (at your option) any later version.
14
15   This Program is distributed in the hope that it will be useful, but WITHOUT ANY
16   WARRANTY, either expressed or implied; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
18
19   You should have received a copy of the GNU General Public License along with this
20   Program (see README files); if not, go to the GNU website (http://www.gnu.org/).
21
22   Redistribution and use, with or without modification, are permitted provided that such
23   redistributions retain the above copyright notice, license and disclaimer, along with
24   this list of conditions.
25 */

26
27 package it.stefanochizzolini.clown.documents.contents.xObjects;
28
29 import it.stefanochizzolini.clown.documents.Document;
30 import it.stefanochizzolini.clown.objects.PdfDirectObject;
31 import it.stefanochizzolini.clown.objects.PdfInteger;
32 import it.stefanochizzolini.clown.objects.PdfName;
33 import it.stefanochizzolini.clown.objects.PdfStream;
34 import it.stefanochizzolini.clown.util.NotImplementedException;
35
36 /**
37   Image external object [PDF:1.6:4.8.4].
38 */

39 public class ImageXObject
40   extends XObject
41 {
42   // <class>
43
// <dynamic>
44
// <constructors>
45
public ImageXObject(
46     Document context,
47     PdfStream baseDataObject
48     )
49   {
50     /*
51       NOTE: It's caller responsability to adequately populate the stream
52       header and body in order to instantiate a valid object; header entries like
53       'Width', 'Height', 'ColorSpace', 'BitsPerComponent' MUST be defined
54       appropriately.
55     */

56
57     super(
58       context,
59       baseDataObject
60       );
61
62     baseDataObject.getHeader().put(PdfName.Subtype,PdfName.Image);
63   }
64
65   /**
66     <h3>Remarks</h3>
67     <p>For internal use only.</p>
68   */

69   public ImageXObject(
70     PdfDirectObject baseObject
71     )
72   {super(baseObject);}
73   // </constructors>
74

75   // <interface>
76
// <public>
77
/**
78     Gets the number of bits per color component.
79   */

80   public int getBitsPerComponent(
81     )
82   {return ((PdfInteger)getBaseDataObject().getHeader().get(PdfName.BitsPerComponent)).getValue();}
83
84   public Object JavaDoc clone(
85     Document context
86     )
87   {throw new NotImplementedException();}
88
89   /**
90     Gets the color space in which samples are specified.
91   */

92   public String JavaDoc getColorSpace(
93     )
94   {return ((PdfName)getBaseDataObject().getHeader().get(PdfName.ColorSpace)).getValue();}
95
96   /**
97     Gets the height of the image (in samples).
98   */

99   public int getHeight(
100     )
101   {return ((PdfInteger)getBaseDataObject().getHeader().get(PdfName.Height)).getValue();}
102
103   /**
104     Gets the width of the image (in samples).
105   */

106   public int getWidth(
107     )
108   {return ((PdfInteger)getBaseDataObject().getHeader().get(PdfName.Width)).getValue();}
109   // </public>
110
// </interface>
111
// </dynamic>
112
// </class>
113
}
Popular Tags