Scribus
Open source desktop publishing at your fingertips
exif.h
1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 #ifndef __EXIF_H__
8 #define __EXIF_H__
9 
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <math.h>
17 #include <time.h>
18 
19 #include "qstring.h"
20 #include "qfile.h"
21 #include "qimage.h"
22 
23 typedef enum {
24  READ_EXIF = 1,
25  READ_IMAGE = 2,
26  READ_ALL = 3
27 }ReadMode_t;
28 
29 //--------------------------------------------------------------------------
30 // This structure is used to store jpeg file sections in memory.
31 /*
32 typedef struct
33 {
34  uchar * Data;
35  int Type;
36  unsigned Size;
37 }
38 Section_t;
39 */
40 typedef unsigned char uchar;
41 
42 class TagTable
43 {
44  public:
45  TagTable ( unsigned short t, const char* d ) : Tag ( t ), Desc ( d ) {}
46  unsigned short Tag;
47  const char*const Desc;
48 };
49 
50 #define MAX_SECTIONS 60
51 #define PSEUDO_IMAGE_MARKER 0x123; // Extra value.
52 
53 class ExifData
54 {
55 // Section_t Sections[MAX_SECTIONS];
56  QString CameraMake;
57  QString CameraModel;
58  QString DateTime;
59  int Orientation;
60  int orientationCount;
61  int Height, Width;
62  int ExifImageLength, ExifImageWidth;
63  int IsColor;
64  int Process;
65  int FlashUsed;
66  float FocalLength;
67  float ExposureTime;
68  float ApertureFNumber;
69  float Distance;
70  int Whitebalance;
71  int MeteringMode;
72  float CCDWidth;
73  float ExposureBias;
74  int ExposureProgram;
75  int ISOequivalent;
76  int CompressionLevel;
77  QString UserComment;
78  QString Comment;
79  int recurseLevel;
80  unsigned char * LastExifRefd;
81  int ExifSettingsLength;
82  double FocalplaneXRes;
83  double FocalplaneUnits;
84  int MotorolaOrder;
85 
86  int getch ( QFile &infile );
87  int ReadJpegSections ( QFile & infile, ReadMode_t ReadMode );
88  void DiscardData ( void );
89  int Get16u ( void * Short );
90  int Get32s ( void * Long );
91  unsigned Get32u ( void * Long );
92  double ConvertAnyFormat ( void * ValuePtr, int Format );
93  void ProcessExifDir ( unsigned char * DirStart, unsigned char * OffsetBase, unsigned ExifLength );
94  void process_COM ( const uchar * Data, int length );
95  void process_SOFn ( const uchar * Data, int marker );
96  int Get16m ( const void * Short );
97  void process_EXIF ( unsigned char * CharBuf, unsigned int length );
98  int Exif2tm ( struct tm * timeptr, char * ExifTime );
99 
100  public:
101  ExifData();
102  bool scan ( const QString & );
103  QString getCameraMake() { return CameraMake; }
104  QString getCameraModel() { return CameraModel; }
105  QString getDateTime() { return DateTime; }
106  int getOrientation() { return Orientation; }
107  int getHeight() { return Height; }
108  int getWidth() { return Width; }
109  int getIsColor() { return IsColor; }
110  int getProcess() { return Process; }
111  int getFlashUsed() { return FlashUsed; }
112  float getFocalLength() { return FocalLength; }
113  float getExposureTime() { return ExposureTime; }
114  float getApertureFNumber() { return ApertureFNumber; }
115  float getDistance() { return Distance; }
116  int getWhitebalance() { return Whitebalance; }
117  int getMeteringMode() { return MeteringMode; }
118  float getCCDWidth() { return CCDWidth; }
119  float getExposureBias() { return ExposureBias; }
120  int getExposureProgram() { return ExposureProgram; }
121  int getISOequivalent() { return ISOequivalent; }
122  int getCompressionLevel() { return CompressionLevel; }
123  QString getUserComment() { return UserComment; }
124  QString getComment() { return Comment; }
125  QImage getThumbnail();
126  bool isThumbnailSane();
127  bool isNullThumbnail() { return !isThumbnailSane(); }
128  bool exifDataValid;
129  QImage Thumbnail;
130 };
131 
133 {
134  const char* ex;
135  public:
136  FatalError ( const char* s ) { ex = s; }
137  void debug_print() const { qDebug ( "exception: " ); }
138 };
139 
140 extern TagTable ProcessTable[];
141 
142 //--------------------------------------------------------------------------
143 // Define comment writing code, impelemented in setcomment.c
144 extern int safe_copy_and_modify ( const char * original_filename, const char * comment );
145 
146 #endif
147 
Definition: exif.h:53
Definition: exif.h:132
Definition: exif.h:42