1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
|
/*****************************************************************************/
// Copyright 2006-2012 Adobe Systems Incorporated
// All Rights Reserved.
//
// NOTICE: Adobe permits you to use, modify, and distribute this file in
// accordance with the terms of the Adobe license agreement accompanying it.
/*****************************************************************************/
/* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_image_writer.h#3 $ */
/* $DateTime: 2012/07/31 22:04:34 $ */
/* $Change: 840853 $ */
/* $Author: tknoll $ */
/** \file
* Support for writing DNG images to files.
*/
/*****************************************************************************/
#ifndef __dng_image_writer__
#define __dng_image_writer__
/*****************************************************************************/
#include "dng_auto_ptr.h"
#include "dng_classes.h"
#include "dng_fingerprint.h"
#include "dng_memory.h"
#include "dng_point.h"
#include "dng_rational.h"
#include "dng_sdk_limits.h"
#include "dng_string.h"
#include "dng_tag_types.h"
#include "dng_tag_values.h"
#include "dng_types.h"
/*****************************************************************************/
/// \brief Image resolution.
class dng_resolution
{
public:
dng_urational fXResolution;
dng_urational fYResolution;
uint16 fResolutionUnit;
public:
dng_resolution ();
};
/*****************************************************************************/
class tiff_tag
{
protected:
uint16 fCode;
uint16 fType;
uint32 fCount;
protected:
tiff_tag (uint16 code,
uint16 type,
uint32 count)
: fCode (code)
, fType (type)
, fCount (count)
{
}
public:
virtual ~tiff_tag ()
{
}
uint16 Code () const
{
return fCode;
}
uint16 Type () const
{
return fType;
}
uint32 Count () const
{
return fCount;
}
void SetCount (uint32 count)
{
fCount = count;
}
uint32 Size () const
{
return TagTypeSize (Type ()) * Count ();
}
virtual void Put (dng_stream &stream) const = 0;
private:
// Hidden copy constructor and assignment operator.
tiff_tag (const tiff_tag &tag);
tiff_tag & operator= (const tiff_tag &tag);
};
/******************************************************************************/
class tag_data_ptr: public tiff_tag
{
protected:
const void *fData;
public:
tag_data_ptr (uint16 code,
uint16 type,
uint32 count,
const void *data)
: tiff_tag (code, type, count)
, fData (data)
{
}
void SetData (const void *data)
{
fData = data;
}
virtual void Put (dng_stream &stream) const;
private:
// Hidden copy constructor and assignment operator.
tag_data_ptr (const tag_data_ptr &tag);
tag_data_ptr & operator= (const tag_data_ptr &tag);
};
/******************************************************************************/
class tag_string: public tiff_tag
{
protected:
dng_string fString;
public:
tag_string (uint16 code,
const dng_string &s,
bool forceASCII = true);
virtual void Put (dng_stream &stream) const;
};
/******************************************************************************/
class tag_encoded_text: public tiff_tag
{
private:
dng_string fText;
dng_memory_data fUTF16;
public:
tag_encoded_text (uint16 code,
const dng_string &text);
virtual void Put (dng_stream &stream) const;
};
/******************************************************************************/
class tag_uint8: public tag_data_ptr
{
private:
uint8 fValue;
public:
tag_uint8 (uint16 code,
uint8 value = 0)
: tag_data_ptr (code, ttByte, 1, &fValue)
, fValue (value)
{
}
void Set (uint8 value)
{
fValue = value;
}
};
/******************************************************************************/
class tag_uint8_ptr: public tag_data_ptr
{
public:
tag_uint8_ptr (uint16 code,
const uint8 *data,
uint32 count = 1)
: tag_data_ptr (code, ttByte, count, data)
{
}
};
/******************************************************************************/
class tag_uint16: public tag_data_ptr
{
private:
uint16 fValue;
public:
tag_uint16 (uint16 code,
uint16 value = 0)
: tag_data_ptr (code, ttShort, 1, &fValue)
, fValue (value)
{
}
void Set (uint16 value)
{
fValue = value;
}
};
/******************************************************************************/
class tag_int16_ptr: public tag_data_ptr
{
public:
tag_int16_ptr (uint16 code,
const int16 *data,
uint32 count = 1)
: tag_data_ptr (code, ttSShort, count, data)
{
}
};
/******************************************************************************/
class tag_uint16_ptr: public tag_data_ptr
{
public:
tag_uint16_ptr (uint16 code,
const uint16 *data,
uint32 count = 1)
: tag_data_ptr (code, ttShort, count, data)
{
}
};
/******************************************************************************/
class tag_uint32: public tag_data_ptr
{
private:
uint32 fValue;
public:
tag_uint32 (uint16 code,
uint32 value = 0)
: tag_data_ptr (code, ttLong, 1, &fValue)
, fValue (value)
{
}
void Set (uint32 value)
{
fValue = value;
}
};
/******************************************************************************/
class tag_uint32_ptr: public tag_data_ptr
{
public:
tag_uint32_ptr (uint16 code,
const uint32 *data,
uint32 count = 1)
: tag_data_ptr (code, ttLong, count, data)
{
}
};
/******************************************************************************/
class tag_urational: public tag_data_ptr
{
private:
const dng_urational fValue;
public:
tag_urational (uint16 code,
const dng_urational &value)
: tag_data_ptr (code, ttRational, 1, &fValue)
, fValue (value)
{
}
};
/******************************************************************************/
class tag_urational_ptr: public tag_data_ptr
{
public:
tag_urational_ptr (uint16 code,
const dng_urational *data = NULL,
uint32 count = 1)
: tag_data_ptr (code, ttRational, count, data)
{
}
};
/******************************************************************************/
class tag_srational: public tag_data_ptr
{
private:
const dng_srational fValue;
public:
tag_srational (uint16 code,
const dng_srational &value)
: tag_data_ptr (code, ttSRational, 1, &fValue)
, fValue (value)
{
}
};
/******************************************************************************/
class tag_srational_ptr: public tag_data_ptr
{
public:
tag_srational_ptr (uint16 code,
const dng_srational *data = NULL,
uint32 count = 1)
: tag_data_ptr (code, ttSRational, count, data)
{
}
};
/******************************************************************************/
class tag_real64: public tag_data_ptr
{
private:
real64 fValue;
public:
tag_real64 (uint16 code,
real64 value = 0.0)
: tag_data_ptr (code, ttDouble, 1, &fValue)
, fValue (value)
{
}
void Set (real64 value)
{
fValue = value;
}
};
/******************************************************************************/
class tag_matrix: public tag_srational_ptr
{
private:
dng_srational fEntry [kMaxColorPlanes *
kMaxColorPlanes];
public:
tag_matrix (uint16 code,
const dng_matrix &m);
};
/******************************************************************************/
class tag_icc_profile: public tag_data_ptr
{
public:
tag_icc_profile (const void *profileData, uint32 profileSize);
};
/******************************************************************************/
class tag_cfa_pattern: public tiff_tag
{
private:
uint32 fRows;
uint32 fCols;
const uint8 *fPattern;
public:
tag_cfa_pattern (uint16 code,
uint32 rows,
uint32 cols,
const uint8 *pattern)
: tiff_tag (code, ttUndefined, 4 + rows * cols)
, fRows (rows )
, fCols (cols )
, fPattern (pattern)
{
}
virtual void Put (dng_stream &stream) const;
private:
// Hidden copy constructor and assignment operator.
tag_cfa_pattern (const tag_cfa_pattern &tag);
tag_cfa_pattern & operator= (const tag_cfa_pattern &tag);
};
/******************************************************************************/
class tag_exif_date_time: public tag_data_ptr
{
private:
char fData [20];
public:
tag_exif_date_time (uint16 code,
const dng_date_time &dt);
};
/******************************************************************************/
class tag_iptc: public tiff_tag
{
private:
const void *fData;
uint32 fLength;
public:
tag_iptc (const void *data,
uint32 length);
virtual void Put (dng_stream &stream) const;
private:
// Hidden copy constructor and assignment operator.
tag_iptc (const tag_iptc &tag);
tag_iptc & operator= (const tag_iptc &tag);
};
/******************************************************************************/
class tag_xmp: public tag_uint8_ptr
{
private:
AutoPtr<dng_memory_block> fBuffer;
public:
tag_xmp (const dng_xmp *xmp);
private:
// Hidden copy constructor and assignment operator.
tag_xmp (const tag_xmp &tag);
tag_xmp & operator= (const tag_xmp &tag);
};
/******************************************************************************/
class dng_tiff_directory
{
private:
enum
{
kMaxEntries = 100
};
uint32 fEntries;
const tiff_tag *fTag [kMaxEntries];
uint32 fChained;
public:
dng_tiff_directory ()
: fEntries (0)
, fChained (0)
{
}
virtual ~dng_tiff_directory ()
{
}
void Add (const tiff_tag *tag);
void SetChained (uint32 offset)
{
fChained = offset;
}
uint32 Size () const;
enum OffsetsBase
{
offsetsRelativeToStream = 0,
offsetsRelativeToExplicitBase = 1,
offsetsRelativeToIFD = 2
};
void Put (dng_stream &stream,
OffsetsBase offsetsBase = offsetsRelativeToStream,
uint32 explicitBase = 0) const;
private:
// Hidden copy constructor and assignment operator.
dng_tiff_directory (const dng_tiff_directory &dir);
dng_tiff_directory & operator= (const dng_tiff_directory &dir);
};
/******************************************************************************/
class dng_basic_tag_set
{
private:
tag_uint32 fNewSubFileType;
tag_uint32 fImageWidth;
tag_uint32 fImageLength;
tag_uint16 fPhotoInterpretation;
tag_uint16 fFillOrder;
tag_uint16 fSamplesPerPixel;
uint16 fBitsPerSampleData [kMaxSamplesPerPixel];
tag_uint16_ptr fBitsPerSample;
bool fStrips;
tag_uint32 fTileWidth;
tag_uint32 fTileLength;
dng_memory_data fTileInfoBuffer;
uint32 *fTileOffsetData;
tag_uint32_ptr fTileOffsets;
uint32 *fTileByteCountData;
tag_uint32_ptr fTileByteCounts;
tag_uint16 fPlanarConfiguration;
tag_uint16 fCompression;
tag_uint16 fPredictor;
uint16 fExtraSamplesData [kMaxSamplesPerPixel];
tag_uint16_ptr fExtraSamples;
uint16 fSampleFormatData [kMaxSamplesPerPixel];
tag_uint16_ptr fSampleFormat;
tag_uint16 fRowInterleaveFactor;
uint16 fSubTileBlockSizeData [2];
tag_uint16_ptr fSubTileBlockSize;
public:
dng_basic_tag_set (dng_tiff_directory &directory,
const dng_ifd &info);
virtual ~dng_basic_tag_set ()
{
}
void SetTileOffset (uint32 index,
uint32 offset)
{
fTileOffsetData [index] = offset;
}
void SetTileByteCount (uint32 index,
uint32 count)
{
fTileByteCountData [index] = count;
}
bool WritingStrips () const
{
return fStrips;
}
private:
// Hidden copy constructor and assignment operator.
dng_basic_tag_set (const dng_basic_tag_set &set);
dng_basic_tag_set & operator= (const dng_basic_tag_set &set);
};
/******************************************************************************/
class exif_tag_set
{
protected:
dng_tiff_directory fExifIFD;
dng_tiff_directory fGPSIFD;
private:
tag_uint32 fExifLink;
tag_uint32 fGPSLink;
bool fAddedExifLink;
bool fAddedGPSLink;
uint8 fExifVersionData [4];
tag_data_ptr fExifVersion;
tag_urational fExposureTime;
tag_srational fShutterSpeedValue;
tag_urational fFNumber;
tag_urational fApertureValue;
tag_srational fBrightnessValue;
tag_srational fExposureBiasValue;
tag_urational fMaxApertureValue;
tag_urational fSubjectDistance;
tag_urational fFocalLength;
tag_uint16 fISOSpeedRatings;
tag_uint16 fSensitivityType;
tag_uint32 fStandardOutputSensitivity;
tag_uint32 fRecommendedExposureIndex;
tag_uint32 fISOSpeed;
tag_uint32 fISOSpeedLatitudeyyy;
tag_uint32 fISOSpeedLatitudezzz;
tag_uint16 fFlash;
tag_uint16 fExposureProgram;
tag_uint16 fMeteringMode;
tag_uint16 fLightSource;
tag_uint16 fSensingMethod;
tag_uint16 fFocalLength35mm;
uint8 fFileSourceData;
tag_data_ptr fFileSource;
uint8 fSceneTypeData;
tag_data_ptr fSceneType;
tag_cfa_pattern fCFAPattern;
tag_uint16 fCustomRendered;
tag_uint16 fExposureMode;
tag_uint16 fWhiteBalance;
tag_uint16 fSceneCaptureType;
tag_uint16 fGainControl;
tag_uint16 fContrast;
tag_uint16 fSaturation;
tag_uint16 fSharpness;
tag_uint16 fSubjectDistanceRange;
tag_urational fDigitalZoomRatio;
tag_urational fExposureIndex;
tag_uint32 fImageNumber;
tag_uint16 fSelfTimerMode;
tag_string fBatteryLevelA;
tag_urational fBatteryLevelR;
tag_urational fFocalPlaneXResolution;
tag_urational fFocalPlaneYResolution;
tag_uint16 fFocalPlaneResolutionUnit;
uint16 fSubjectAreaData [4];
tag_uint16_ptr fSubjectArea;
dng_urational fLensInfoData [4];
tag_urational_ptr fLensInfo;
tag_exif_date_time fDateTime;
tag_exif_date_time fDateTimeOriginal;
tag_exif_date_time fDateTimeDigitized;
tag_string fSubsecTime;
tag_string fSubsecTimeOriginal;
tag_string fSubsecTimeDigitized;
tag_string fMake;
tag_string fModel;
tag_string fArtist;
tag_string fSoftware;
tag_string fCopyright;
tag_string fImageDescription;
tag_string fSerialNumber;
tag_uint16 fMakerNoteSafety;
tag_data_ptr fMakerNote;
tag_encoded_text fUserComment;
char fImageUniqueIDData [33];
tag_data_ptr fImageUniqueID;
// EXIF 2.3 tags.
tag_string fCameraOwnerName;
tag_string fBodySerialNumber;
tag_urational_ptr fLensSpecification;
tag_string fLensMake;
tag_string fLensModel;
tag_string fLensSerialNumber;
uint8 fGPSVersionData [4];
tag_uint8_ptr fGPSVersionID;
tag_string fGPSLatitudeRef;
tag_urational_ptr fGPSLatitude;
tag_string fGPSLongitudeRef;
tag_urational_ptr fGPSLongitude;
tag_uint8 fGPSAltitudeRef;
tag_urational fGPSAltitude;
tag_urational_ptr fGPSTimeStamp;
tag_string fGPSSatellites;
tag_string fGPSStatus;
tag_string fGPSMeasureMode;
tag_urational fGPSDOP;
tag_string fGPSSpeedRef;
tag_urational fGPSSpeed;
tag_string fGPSTrackRef;
tag_urational fGPSTrack;
tag_string fGPSImgDirectionRef;
tag_urational fGPSImgDirection;
tag_string fGPSMapDatum;
tag_string fGPSDestLatitudeRef;
tag_urational_ptr fGPSDestLatitude;
tag_string fGPSDestLongitudeRef;
tag_urational_ptr fGPSDestLongitude;
tag_string fGPSDestBearingRef;
tag_urational fGPSDestBearing;
tag_string fGPSDestDistanceRef;
tag_urational fGPSDestDistance;
tag_encoded_text fGPSProcessingMethod;
tag_encoded_text fGPSAreaInformation;
tag_string fGPSDateStamp;
tag_uint16 fGPSDifferential;
tag_urational fGPSHPositioningError;
public:
exif_tag_set (dng_tiff_directory &directory,
const dng_exif &exif,
bool makerNoteSafe = false,
const void *makerNoteData = NULL,
uint32 makerNoteLength = 0,
bool insideDNG = false);
void Locate (uint32 offset)
{
fExifLink.Set (offset);
fGPSLink .Set (offset + fExifIFD.Size ());
}
uint32 Size () const
{
return fExifIFD.Size () +
fGPSIFD .Size ();
}
void Put (dng_stream &stream) const
{
fExifIFD.Put (stream);
fGPSIFD .Put (stream);
}
protected:
void AddLinks (dng_tiff_directory &directory);
private:
// Hidden copy constructor and assignment operator.
exif_tag_set (const exif_tag_set &set);
exif_tag_set & operator= (const exif_tag_set &set);
};
/******************************************************************************/
class tiff_dng_extended_color_profile: private dng_tiff_directory
{
protected:
const dng_camera_profile &fProfile;
public:
tiff_dng_extended_color_profile (const dng_camera_profile &profile);
void Put (dng_stream &stream,
bool includeModelRestriction = true);
};
/*****************************************************************************/
class tag_dng_noise_profile: public tag_data_ptr
{
protected:
real64 fValues [2 * kMaxColorPlanes];
public:
explicit tag_dng_noise_profile (const dng_noise_profile &profile);
};
/*****************************************************************************/
// Enum to control the subset of metadata to save to a file.
enum dng_metadata_subset
{
kMetadataSubset_CopyrightOnly = 0,
kMetadataSubset_CopyrightAndContact,
kMetadataSubset_AllExceptCameraInfo,
kMetadataSubset_All,
kMetadataSubset_AllExceptLocationInfo,
kMetadataSubset_AllExceptCameraAndLocation,
kMetadataSubset_Last = kMetadataSubset_AllExceptCameraAndLocation
};
/*****************************************************************************/
/// \brief Support for writing dng_image or dng_negative instances to a
/// dng_stream in TIFF or DNG format.
class dng_image_writer
{
bool fComputeMd5Sum; // Set to true to compute md5sum
friend class dng_jpeg_image;
friend class dng_jpeg_image_encode_task;
friend class dng_write_tiles_task;
protected:
enum
{
// Target size for buffer used to copy data to the image.
kImageBufferSize = 128 * 1024
};
public:
dng_image_writer ();
virtual ~dng_image_writer ();
#if GPR_WRITING
virtual uint32 GetDefaultCompression() { return ccJPEG; }
#endif
void SetComputeMd5Sum(bool x) { fComputeMd5Sum = x; }
virtual void EncodeJPEGPreview (dng_host &host,
const dng_image &image,
dng_jpeg_preview &preview,
int32 quality = -1);
virtual void WriteImage (dng_host &host,
const dng_ifd &ifd,
dng_basic_tag_set &basic,
dng_stream &stream,
const dng_image &image,
uint32 fakeChannels = 1);
/// Write a dng_image to a dng_stream in TIFF format.
/// \param host Host interface used for progress updates, abort testing, buffer allocation, etc.
/// \param stream The dng_stream on which to write the TIFF.
/// \param image The actual image data to be written.
/// \param photometricInterpretation Either piBlackIsZero for monochrome or piRGB for RGB images.
/// \param compression Must be ccUncompressed.
/// \param negative or metadata If non-NULL, EXIF, IPTC, and XMP metadata from this negative is written to TIFF.
/// \param space If non-null and color space has an ICC profile, TIFF will be tagged with this
/// profile. No color space conversion of image data occurs.
/// \param resolution If non-NULL, TIFF will be tagged with this resolution.
/// \param thumbnail If non-NULL, will be stored in TIFF as preview image.
/// \param imageResources If non-NULL, will image resources be stored in TIFF as well.
/// \param metadataSubset The subset of metadata (e.g., copyright only) to include in the TIFF.
void WriteTIFF (dng_host &host,
dng_stream &stream,
const dng_image &image,
uint32 photometricInterpretation,
uint32 compression,
dng_negative *negative,
const dng_color_space *space = NULL,
const dng_resolution *resolution = NULL,
const dng_jpeg_preview *thumbnail = NULL,
const dng_memory_block *imageResources = NULL,
dng_metadata_subset metadataSubset = kMetadataSubset_All);
void WriteTIFF (dng_host &host,
dng_stream &stream,
const dng_image &image,
uint32 photometricInterpretation = piBlackIsZero,
uint32 compression = ccUncompressed,
const dng_metadata *metadata = NULL,
const dng_color_space *space = NULL,
const dng_resolution *resolution = NULL,
const dng_jpeg_preview *thumbnail = NULL,
const dng_memory_block *imageResources = NULL,
dng_metadata_subset metadataSubset = kMetadataSubset_All);
/// Write a dng_image to a dng_stream in TIFF format.
/// \param host Host interface used for progress updates, abort testing, buffer allocation, etc.
/// \param stream The dng_stream on which to write the TIFF.
/// \param image The actual image data to be written.
/// \param photometricInterpretation Either piBlackIsZero for monochrome or piRGB for RGB images.
/// \param compression Must be ccUncompressed.
/// \param negative or metadata If non-NULL, EXIF, IPTC, and XMP metadata from this negative is written to TIFF.
/// \param profileData If non-null, TIFF will be tagged with this profile. No color space conversion
/// of image data occurs.
/// \param profileSize The size for the profile data.
/// \param resolution If non-NULL, TIFF will be tagged with this resolution.
/// \param thumbnail If non-NULL, will be stored in TIFF as preview image.
/// \param imageResources If non-NULL, will image resources be stored in TIFF as well.
/// \param metadataSubset The subset of metadata (e.g., copyright only) to include in the TIFF.
void WriteTIFFWithProfile (dng_host &host,
dng_stream &stream,
const dng_image &image,
uint32 photometricInterpretation,
uint32 compression,
dng_negative *negative,
const void *profileData = NULL,
uint32 profileSize = 0,
const dng_resolution *resolution = NULL,
const dng_jpeg_preview *thumbnail = NULL,
const dng_memory_block *imageResources = NULL,
dng_metadata_subset metadataSubset = kMetadataSubset_All);
virtual void WriteTIFFWithProfile (dng_host &host,
dng_stream &stream,
const dng_image &image,
uint32 photometricInterpretation = piBlackIsZero,
uint32 compression = ccUncompressed,
const dng_metadata *metadata = NULL,
const void *profileData = NULL,
uint32 profileSize = 0,
const dng_resolution *resolution = NULL,
const dng_jpeg_preview *thumbnail = NULL,
const dng_memory_block *imageResources = NULL,
dng_metadata_subset metadataSubset = kMetadataSubset_All);
/// Write a dng_image to a dng_stream in DNG format.
/// \param host Host interface used for progress updates, abort testing, buffer allocation, etc.
/// \param stream The dng_stream on which to write the TIFF.
/// \param negative The image data and metadata (EXIF, IPTC, XMP) to be written.
/// \param previewList List of previews (not counting thumbnail) to write to the file. Defaults to empty.
/// \param maxBackwardVersion The DNG file should be readable by readers at least back to this version.
/// \param uncompressed True to force uncompressed images. Otherwise use normal compression.
void WriteDNG (dng_host &host,
dng_stream &stream,
dng_negative &negative,
const dng_preview_list *previewList = NULL,
uint32 maxBackwardVersion = dngVersion_SaveDefault,
bool uncompressed = false);
/// Write a dng_image to a dng_stream in DNG format.
/// \param host Host interface used for progress updates, abort testing, buffer allocation, etc.
/// \param stream The dng_stream on which to write the TIFF.
/// \param negative The image data to be written.
/// \param metadata The metadata (EXIF, IPTC, XMP) to be written.
/// \param previewList List of previews (not counting thumbnail) to write to the file. Defaults to empty.
/// \param maxBackwardVersion The DNG file should be readable by readers at least back to this version.
/// \param uncompressed True to force uncompressed images. Otherwise use normal compression.
virtual void WriteDNG (dng_host &host,
dng_stream &stream,
const dng_negative &negative,
const dng_metadata &metadata,
const dng_preview_list *previewList = NULL,
uint32 maxBackwardVersion = dngVersion_SaveDefault,
bool uncompressed = false);
/// Resolve metadata conflicts and apply metadata policies in keeping
/// with Metadata Working Group (MWG) guidelines.
virtual void CleanUpMetadata (dng_host &host,
dng_metadata &metadata,
dng_metadata_subset metadataSubset,
const char *dstMIMI,
const char *software = NULL);
protected:
virtual uint32 CompressedBufferSize (const dng_ifd &ifd,
uint32 uncompressedSize);
virtual void EncodePredictor (dng_host &host,
const dng_ifd &ifd,
dng_pixel_buffer &buffer,
AutoPtr<dng_memory_block> &tempBuffer);
virtual void ByteSwapBuffer (dng_host &host,
dng_pixel_buffer &buffer);
void ReorderSubTileBlocks (const dng_ifd &ifd,
dng_pixel_buffer &buffer,
AutoPtr<dng_memory_block> &uncompressedBuffer,
AutoPtr<dng_memory_block> &subTileBlockBuffer);
virtual void WriteData (dng_host &host,
const dng_ifd &ifd,
dng_stream &stream,
dng_pixel_buffer &buffer,
AutoPtr<dng_memory_block> &compressedBuffer);
virtual void WriteTile (dng_host &host,
const dng_ifd &ifd,
dng_stream &stream,
const dng_image &image,
const dng_rect &tileArea,
uint32 fakeChannels,
AutoPtr<dng_memory_block> &compressedBuffer,
AutoPtr<dng_memory_block> &uncompressedBuffer,
AutoPtr<dng_memory_block> &subTileBlockBuffer,
AutoPtr<dng_memory_block> &tempBuffer);
};
/*****************************************************************************/
#endif
/*****************************************************************************/
|