Debian Codegraph @

core/libs/dngwriter/extra/dng_sdk/dng_preview.h

raw
1 /*****************************************************************************/
2 // Copyright 2007-2023 Adobe Systems Incorporated
3 // All Rights Reserved.
4 //
5 // NOTICE: Adobe permits you to use, modify, and distribute this file in
6 // accordance with the terms of the Adobe license agreement accompanying it.
7 /*****************************************************************************/
8
9 #ifndef __dng_preview__
10 #define __dng_preview__
11
12 /*****************************************************************************/
13
14 #include "dng_auto_ptr.h"
15 #include "dng_classes.h"
16 #include "dng_ifd.h"
17 #include "dng_opcode_list.h"
18 #include "dng_point.h"
19 #include "dng_sdk_limits.h"
20 #include "dng_string.h"
21 #include "dng_uncopyable.h"
22
23 #include <memory>
24
25 /*****************************************************************************/
26
27 class dng_preview: private dng_uncopyable
28 {
29
30 public:
31
32 dng_preview_info fInfo;
33
34 bool fPreferJXL = false;
35
36 bool fForNegativeCache = false;
37
38 // protected:
39
40 std::shared_ptr<const dng_image> fImage;
41
42 std::shared_ptr<const dng_compressed_image_tiles> fCompressedImage;
43
44 mutable dng_ifd fIFD;
45
46 protected:
47
48 dng_preview ()
49 {
50 }
51
52 public:
53
54 virtual ~dng_preview ()
55 {
56 }
57
58 virtual void SetIFDInfo (dng_host &host,
59 const dng_image &image);
60
61 void FindTileSize (uint32 bytesPerTile)
62 {
63 fIFD.FindTileSize (bytesPerTile);
64 }
65
66 void SetImage (dng_host &host,
67 std::shared_ptr<const dng_image> image)
68 {
69
70 fImage = image;
71
72 SetIFDInfo (host, *fImage);
73
74 }
75
76 void SetImage (dng_host &host,
77 AutoPtr<dng_image> &image)
78 {
79
80 std::shared_ptr<const dng_image> temp (image.Release ());
81
82 SetImage (host, temp);
83
84 }
85
86 void SetImage (dng_host &host,
87 const dng_image *image)
88 {
89
90 std::shared_ptr<const dng_image> temp (image);
91
92 SetImage (host, temp);
93
94 }
95
96 uint32 ImageWidth () const
97 {
98 return fIFD.fImageWidth;
99 }
100
101 uint32 ImageLength () const
102 {
103 return fIFD.fImageLength;
104 }
105
106 uint32 SamplesPerPixel () const
107 {
108 return fIFD.fSamplesPerPixel;
109 }
110
111 uint32 BitsPerSample () const
112 {
113 return fIFD.fBitsPerSample [0];
114 }
115
116 uint32 SampleFormat () const
117 {
118 return fIFD.fSampleFormat [0];
119 }
120
121 uint32 PhotometricInterpretation () const
122 {
123 return fIFD.fPhotometricInterpretation;
124 }
125
126 uint32 NewSubFileType () const
127 {
128 return fIFD.fNewSubFileType;
129 }
130
131 virtual dng_basic_tag_set * AddTagSet (dng_host &host,
132 dng_tiff_directory &directory) const;
133
134 virtual void WriteData (dng_host &host,
135 dng_image_writer &writer,
136 dng_basic_tag_set &basic,
137 dng_stream &stream) const;
138
139 virtual uint64 MaxImageDataByteCount () const;
140
141 virtual void Compress (dng_host &host,
142 dng_image_writer &writer);
143
144 };
145
146 /*****************************************************************************/
147
148 class dng_image_preview: public dng_preview
149 {
150
151 public:
152
153 dng_image_preview ()
154 {
155 }
156
157 };
158
159 /*****************************************************************************/
160
161 class dng_jpeg_preview: public dng_preview
162 {
163
164 public:
165
166 dng_jpeg_preview ()
167 {
168 }
169
170 void SetIFDInfo (dng_host &host,
171 const dng_image &image) override;
172
173 void SetCompressionQuality (uint32 quality)
174 {
175 fIFD.fCompressionQuality = quality;
176 }
177
178 void SetYCbCr (uint32 subSampleH,
179 uint32 subSampleV)
180 {
181
182 fIFD.fPhotometricInterpretation = piYCbCr;
183
184 fIFD.fYCbCrSubSampleH = subSampleH;
185 fIFD.fYCbCrSubSampleV = subSampleV;
186
187 }
188
189 void SetCompressedData (AutoPtr<dng_memory_block> &compressedData);
190
191 const dng_memory_block & CompressedData () const;
192
193 dng_basic_tag_set * AddTagSet (dng_host &host,
194 dng_tiff_directory &directory) const override;
195
196 void WriteData (dng_host &host,
197 dng_image_writer &writer,
198 dng_basic_tag_set &basic,
199 dng_stream &stream) const override;
200
201 uint64 MaxImageDataByteCount () const override;
202
203 void Compress (dng_host &host,
204 dng_image_writer &writer) override;
205
206 void SpoolAdobeThumbnail (dng_stream &stream) const;
207
208 };
209
210 /*****************************************************************************/
211
212 class dng_jxl_preview: public dng_preview
213 {
214
215 public:
216
217 dng_jxl_preview ()
218 {
219 }
220
221 void SetIFDInfo (dng_host &host,
222 const dng_image &image) override;
223
224 };
225
226 /*****************************************************************************/
227
228 class dng_raw_preview: public dng_preview
229 {
230
231 public:
232
233 AutoPtr<dng_memory_block> fOpcodeList2Data;
234
235 real64 fBlackLevel [kMaxColorPlanes];
236
237 int32 fCompressionQuality = -1;
238
239 public:
240
241 dng_raw_preview ();
242
243 virtual void SetIFDInfo (dng_host &host,
244 const dng_image &image);
245
246 virtual dng_basic_tag_set * AddTagSet (dng_host &host,
247 dng_tiff_directory &directory) const;
248
249 };
250
251 /*****************************************************************************/
252
253 class dng_mask_preview: public dng_preview
254 {
255
256 public:
257
258 int32 fCompressionQuality = -1;
259
260 public:
261
262 dng_mask_preview ()
263 {
264 }
265
266 virtual void SetIFDInfo (dng_host &host,
267 const dng_image &image);
268
269 virtual dng_basic_tag_set * AddTagSet (dng_host &host,
270 dng_tiff_directory &directory) const;
271
272 };
273
274 /*****************************************************************************/
275
276 class dng_semantic_mask_preview: public dng_preview
277 {
278
279 public:
280
281 // Don't bother with including XMP block (if any) because this is just
282 // a preview.
283
284 dng_string fName;
285
286 dng_string fInstanceID;
287
288 int32 fCompressionQuality = -1;
289
290 bool fOriginalSize = false;
291
292 uint32 fMaskSubArea [4];
293
294 private:
295
296 mutable std::unique_ptr<tag_string> fTagName;
297 mutable std::unique_ptr<tag_string> fTagInstanceID;
298
299 mutable std::unique_ptr<tag_uint32_ptr> fTagMaskSubArea;
300
301 public:
302
303 dng_semantic_mask_preview ()
304 {
305 fMaskSubArea [0] = 0;
306 fMaskSubArea [1] = 0;
307 fMaskSubArea [2] = 0;
308 fMaskSubArea [3] = 0;
309 }
310
311 virtual void SetIFDInfo (dng_host &host,
312 const dng_image &image);
313
314 virtual dng_basic_tag_set * AddTagSet (dng_host &host,
315 dng_tiff_directory &directory) const;
316
317 };
318
319 /*****************************************************************************/
320
321 class dng_depth_preview: public dng_preview
322 {
323
324 public:
325
326 int32 fCompressionQuality = -1;
327
328 bool fFullResolution = false;
329
330 public:
331
332 dng_depth_preview ()
333 {
334 }
335
336 virtual void SetIFDInfo (dng_host &host,
337 const dng_image &image);
338
339 virtual dng_basic_tag_set * AddTagSet (dng_host &host,
340 dng_tiff_directory &directory) const;
341
342 };
343
344 /*****************************************************************************/
345
346 class dng_preview_list
347 {
348
349 private:
350
351 std::vector<std::shared_ptr<const dng_preview>> fPreview;
352
353 public:
354
355 dng_preview_list ()
356 {
357 }
358
359 uint32 Count () const
360 {
361 return (uint32) fPreview.size ();
362 }
363
364 const dng_preview & Preview (uint32 index) const
365 {
366 return *(fPreview [index]);
367 }
368
369 void Append (AutoPtr<dng_preview> &preview);
370
371 };
372
373 /*****************************************************************************/
374
375 #endif
376
377 /*****************************************************************************/