OLD | NEW |
| (Empty) |
1 #ifndef __DEFINED__SkPdfImageDictionary | |
2 #define __DEFINED__SkPdfImageDictionary | |
3 | |
4 #include "SkPdfEnums_autogen.h" | |
5 #include "SkPdfArray_autogen.h" | |
6 #include "SkPdfXObjectDictionary_autogen.h" | |
7 | |
8 // Additional entries specific to an image dictionary | |
9 class SkPdfImageDictionary : public SkPdfXObjectDictionary { | |
10 public: | |
11 virtual SkPdfObjectType getType() const { return kImageDictionary_SkPdfObjectT
ype;} | |
12 virtual SkPdfObjectType getTypeEnd() const { return (SkPdfObjectType)(kImageDi
ctionary_SkPdfObjectType + 1);} | |
13 public: | |
14 virtual SkPdfImageDictionary* asImageDictionary() {return this;} | |
15 virtual const SkPdfImageDictionary* asImageDictionary() const {return this;} | |
16 | |
17 private: | |
18 virtual SkPdfType1FormDictionary* asType1FormDictionary() {return NULL;} | |
19 virtual const SkPdfType1FormDictionary* asType1FormDictionary() const {return
NULL;} | |
20 | |
21 public: | |
22 private: | |
23 public: | |
24 SkPdfImageDictionary(const PdfMemDocument* podofoDoc = NULL, const PdfObject*
podofoObj = NULL) : SkPdfXObjectDictionary(podofoDoc, podofoObj) {} | |
25 | |
26 virtual bool valid() const {return true;} | |
27 | |
28 SkPdfImageDictionary& operator=(const SkPdfImageDictionary& from) {this->fPodo
foDoc = from.fPodofoDoc; this->fPodofoObj = from.fPodofoObj; return *this;} | |
29 | |
30 /** (Optional) The type of PDF object that this dictionary describes; if | |
31 * present, must be XObject for an image XObject. | |
32 **/ | |
33 bool has_Type() const { | |
34 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Type"
, "", NULL)); | |
35 } | |
36 | |
37 std::string Type() const { | |
38 std::string ret; | |
39 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Type", "",
&ret)) return ret; | |
40 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
41 return ""; | |
42 } | |
43 | |
44 /** (Required) The type of XObject that this dictionary describes; must be | |
45 * Image for an image XObject. | |
46 **/ | |
47 bool has_Subtype() const { | |
48 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Subty
pe", "", NULL)); | |
49 } | |
50 | |
51 std::string Subtype() const { | |
52 std::string ret; | |
53 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Subtype", "
", &ret)) return ret; | |
54 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
55 return ""; | |
56 } | |
57 | |
58 /** (Required) The width of the image, in samples. | |
59 **/ | |
60 bool has_Width() const { | |
61 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Width
", "", NULL)); | |
62 } | |
63 | |
64 long Width() const { | |
65 long ret; | |
66 if (LongFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Width", "",
&ret)) return ret; | |
67 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
68 return 0; | |
69 } | |
70 | |
71 /** (Required) The height of the image, in samples. | |
72 **/ | |
73 bool has_Height() const { | |
74 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Heigh
t", "", NULL)); | |
75 } | |
76 | |
77 long Height() const { | |
78 long ret; | |
79 if (LongFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Height", ""
, &ret)) return ret; | |
80 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
81 return 0; | |
82 } | |
83 | |
84 /** (Required except for image masks; not allowed for image masks) The color | |
85 * space in which image samples are specified. This may be any type of color | |
86 * space except Pattern. | |
87 **/ | |
88 bool has_ColorSpace() const { | |
89 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Color
Space", "", NULL)); | |
90 } | |
91 | |
92 bool isColorSpaceAName() const { | |
93 SkPdfObject* ret = NULL; | |
94 if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ColorSpa
ce", "", &ret)) return false; | |
95 return ret->podofo()->GetDataType() == ePdfDataType_Name; | |
96 } | |
97 | |
98 std::string getColorSpaceAsName() const { | |
99 std::string ret = ""; | |
100 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ColorSpace"
, "", &ret)) return ret; | |
101 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
102 return ""; | |
103 } | |
104 | |
105 bool isColorSpaceAArray() const { | |
106 SkPdfObject* ret = NULL; | |
107 if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ColorSpa
ce", "", &ret)) return false; | |
108 return ret->podofo()->GetDataType() == ePdfDataType_Array; | |
109 } | |
110 | |
111 SkPdfArray getColorSpaceAsArray() const { | |
112 SkPdfArray ret = SkPdfArray(); | |
113 if (ArrayFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ColorSpace
", "", &ret)) return ret; | |
114 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
115 return SkPdfArray(); | |
116 } | |
117 | |
118 /** (Required except for image masks; optional for image masks) The number of | |
119 * bits used to represent each color component. Only a single value may be | |
120 * specified; the number of bits is the same for all color components. Valid | |
121 * values are 1, 2, 4, and 8. If ImageMask is true, this entry is optional, and
if | |
122 * specified, its value must be 1. | |
123 * If the image stream uses a filter, the value of BitsPerComponent must be | |
124 * consistent with the size of the data samples that the filter delivers. In pa
r- | |
125 * ticular, a CCITTFaxDecode or JBIG2Decode filter always delivers 1-bit sam- | |
126 * ples, a RunLengthDecode or DCTDecode filter delivers 8-bit samples, and | |
127 * an LZWDecode or FlateDecode filter delivers samples of a specified size if | |
128 * a predictor function is used. | |
129 **/ | |
130 bool has_BitsPerComponent() const { | |
131 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "BitsP
erComponent", "", NULL)); | |
132 } | |
133 | |
134 long BitsPerComponent() const { | |
135 long ret; | |
136 if (LongFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "BitsPerComp
onent", "", &ret)) return ret; | |
137 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
138 return 0; | |
139 } | |
140 | |
141 /** (Optional; PDF 1.1) The name of a color rendering intent to be used in | |
142 * rendering the image (see "Rendering Intents" on page 197). Default value: | |
143 * the current rendering intent in the graphics state. | |
144 **/ | |
145 bool has_Intent() const { | |
146 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Inten
t", "", NULL)); | |
147 } | |
148 | |
149 std::string Intent() const { | |
150 std::string ret; | |
151 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Intent", ""
, &ret)) return ret; | |
152 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
153 return ""; | |
154 } | |
155 | |
156 /** (Optional) A flag indicating whether the image is to be treated as an image | |
157 * mask (see Section 4.8.5, "Masked Images"). If this flag is true, the value o
f | |
158 * BitsPerComponent must be 1 and Mask and ColorSpace should not be | |
159 * specified; unmasked areas will be painted using the current nonstroking | |
160 * color. Default value: false. | |
161 **/ | |
162 bool has_ImageMask() const { | |
163 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Image
Mask", "", NULL)); | |
164 } | |
165 | |
166 bool ImageMask() const { | |
167 bool ret; | |
168 if (BoolFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ImageMask",
"", &ret)) return ret; | |
169 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
170 return false; | |
171 } | |
172 | |
173 /** (Optional except for image masks; not allowed for image masks; PDF 1.3) An | |
174 * image XObject defining an image mask to be applied to this image (see | |
175 * "Explicit Masking" on page 277), or an array specifying a range of colors | |
176 * to be applied to it as a color key mask (see "Color Key Masking" on page | |
177 * 277). If ImageMask is true, this entry must not be present. (See | |
178 * implementation note 35 in Appendix H.) | |
179 **/ | |
180 bool has_Mask() const { | |
181 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Mask"
, "", NULL)); | |
182 } | |
183 | |
184 bool isMaskAStream() const { | |
185 SkPdfObject* ret = NULL; | |
186 if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Mask", "
", &ret)) return false; | |
187 return ret->podofo()->HasStream(); | |
188 } | |
189 | |
190 SkPdfStream* getMaskAsStream() const { | |
191 SkPdfStream* ret = NULL; | |
192 if (StreamFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Mask", ""
, &ret)) return ret; | |
193 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
194 return NULL; | |
195 } | |
196 | |
197 bool isMaskAArray() const { | |
198 SkPdfObject* ret = NULL; | |
199 if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Mask", "
", &ret)) return false; | |
200 return ret->podofo()->GetDataType() == ePdfDataType_Array; | |
201 } | |
202 | |
203 SkPdfArray getMaskAsArray() const { | |
204 SkPdfArray ret = SkPdfArray(); | |
205 if (ArrayFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Mask", "",
&ret)) return ret; | |
206 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
207 return SkPdfArray(); | |
208 } | |
209 | |
210 /** (Optional; PDF 1.4) A subsidiary image XObject defining a soft-mask | |
211 * image (see "Soft-Mask Images" on page 447) to be used as a source of | |
212 * mask shape or mask opacity values in the transparent imaging model. The | |
213 * alpha source parameter in the graphics state determines whether the mask | |
214 * values are interpreted as shape or opacity. | |
215 * If present, this entry overrides the current soft mask in the graphics state
, | |
216 * as well as the image's Mask entry, if any. (However, the other transparency- | |
217 * related graphics state parameters-blend mode and alpha constant- | |
218 * remain in effect.) If SMask is absent, the image has no associated soft mask | |
219 * (although the current soft mask in the graphics state may still apply). | |
220 **/ | |
221 bool has_SMask() const { | |
222 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "SMask
", "", NULL)); | |
223 } | |
224 | |
225 SkPdfStream* SMask() const { | |
226 SkPdfStream* ret; | |
227 if (StreamFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "SMask", "
", &ret)) return ret; | |
228 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
229 return NULL; | |
230 } | |
231 | |
232 /** (Optional) An array of numbers describing how to map image samples | |
233 * into the range of values appropriate for the image's color space (see | |
234 * "Decode Arrays" on page 271). If ImageMask is true, the array must be | |
235 * either [0 1] or [1 0]; otherwise, its length must be twice the number of | |
236 * color components required by ColorSpace. Default value: see "Decode | |
237 * Arrays" on page 271. | |
238 **/ | |
239 bool has_Decode() const { | |
240 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Decod
e", "", NULL)); | |
241 } | |
242 | |
243 SkPdfArray Decode() const { | |
244 SkPdfArray ret; | |
245 if (ArrayFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Decode", "
", &ret)) return ret; | |
246 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
247 return SkPdfArray(); | |
248 } | |
249 | |
250 /** (Optional) A flag indicating whether image interpolation is to be per- | |
251 * formed (see "Image Interpolation" on page 273). Default value: false. | |
252 **/ | |
253 bool has_Interpolate() const { | |
254 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Inter
polate", "", NULL)); | |
255 } | |
256 | |
257 bool Interpolate() const { | |
258 bool ret; | |
259 if (BoolFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Interpolate
", "", &ret)) return ret; | |
260 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
261 return false; | |
262 } | |
263 | |
264 /** (Optional; PDF 1.3) An array of alternate image dictionaries for this image | |
265 * (see "Alternate Images" on page 273). The order of elements within the | |
266 * array has no significance. This entry may not be present in an image | |
267 * XObject that is itself an alternate image. | |
268 **/ | |
269 bool has_Alternates() const { | |
270 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Alter
nates", "", NULL)); | |
271 } | |
272 | |
273 SkPdfArray Alternates() const { | |
274 SkPdfArray ret; | |
275 if (ArrayFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Alternates
", "", &ret)) return ret; | |
276 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
277 return SkPdfArray(); | |
278 } | |
279 | |
280 /** (Required in PDF 1.0; optional otherwise) The name by which this image | |
281 * XObject is referenced in the XObject subdictionary of the current resource | |
282 * dictionary (see Section 3.7.2, "Resource Dictionaries"). | |
283 * Note: This entry is obsolescent and its use is no longer recommended. (See | |
284 * implementation note 36 in Appendix H.) | |
285 **/ | |
286 bool has_Name() const { | |
287 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Name"
, "", NULL)); | |
288 } | |
289 | |
290 std::string Name() const { | |
291 std::string ret; | |
292 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Name", "",
&ret)) return ret; | |
293 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
294 return ""; | |
295 } | |
296 | |
297 /** (Required if the image is a structural content item; PDF 1.3) The integer ke
y | |
298 * of the image's entry in the structural parent tree (see "Finding Structure | |
299 * Elements from Content Items" on page 600). | |
300 **/ | |
301 bool has_StructParent() const { | |
302 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Struc
tParent", "", NULL)); | |
303 } | |
304 | |
305 long StructParent() const { | |
306 long ret; | |
307 if (LongFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "StructParen
t", "", &ret)) return ret; | |
308 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
309 return 0; | |
310 } | |
311 | |
312 /** (Optional; PDF 1.3; indirect reference preferred) The digital identifier of
the | |
313 * image's parent Web Capture content set (see Section 9.9.5, "Object At- | |
314 * tributes Related to Web Capture"). | |
315 **/ | |
316 bool has_ID() const { | |
317 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ID",
"", NULL)); | |
318 } | |
319 | |
320 std::string ID() const { | |
321 std::string ret; | |
322 if (StringFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ID", "",
&ret)) return ret; | |
323 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
324 return ""; | |
325 } | |
326 | |
327 /** (Optional; PDF 1.2) An OPI version dictionary for the image (see Section | |
328 * 9.10.6, "Open Prepress Interface (OPI)"). If ImageMask is true, this entry | |
329 * is ignored. | |
330 **/ | |
331 bool has_OPI() const { | |
332 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "OPI",
"", NULL)); | |
333 } | |
334 | |
335 SkPdfDictionary* OPI() const { | |
336 SkPdfDictionary* ret; | |
337 if (DictionaryFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "OPI",
"", &ret)) return ret; | |
338 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
339 return NULL; | |
340 } | |
341 | |
342 /** (Optional; PDF 1.4) A metadata stream containing metadata for the image | |
343 * (see Section 9.2.2, "Metadata Streams"). | |
344 **/ | |
345 bool has_Metadata() const { | |
346 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Metad
ata", "", NULL)); | |
347 } | |
348 | |
349 SkPdfStream* Metadata() const { | |
350 SkPdfStream* ret; | |
351 if (StreamFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Metadata"
, "", &ret)) return ret; | |
352 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
353 return NULL; | |
354 } | |
355 | |
356 }; | |
357 | |
358 #endif // __DEFINED__SkPdfImageDictionary | |
OLD | NEW |