summaryrefslogtreecommitdiff
path: root/libopie2/opiemm/opieexif.h
Unidiff
Diffstat (limited to 'libopie2/opiemm/opieexif.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiemm/opieexif.h139
1 files changed, 139 insertions, 0 deletions
diff --git a/libopie2/opiemm/opieexif.h b/libopie2/opiemm/opieexif.h
new file mode 100644
index 0000000..efaed71
--- a/dev/null
+++ b/libopie2/opiemm/opieexif.h
@@ -0,0 +1,139 @@
1#ifndef _OPIE_EXIF_H
2#define _OPIE_EXIF_H
3
4#include <qt.h>
5#include <qstring.h>
6#include <qimage.h>
7#include <qfile.h>
8
9#include <time.h>
10
11namespace Opie { namespace MM {
12
13#ifndef uchar
14typedef unsigned char uchar;
15#endif
16
17//#define MAX_SECTIONS 20
18//#define PSEUDO_IMAGE_MARKER 0x123; // Extra value.
19
20//! Class for reading exif data from images
21/*!
22 * This class is mostly used inside OImageScrollView for testing jpegs headers for a faster
23 * loading and scaling. It is taken from libexif and converted into an C++ structure.
24 *
25 * \see OImageScrollView
26 * \since 1.2
27 */
28class ExifData {
29public:
30 enum ReadMode_t {
31 READ_EXIF = 1,
32 READ_IMAGE = 2,
33 READ_ALL = 3
34 };
35
36 //--------------------------------------------------------------------------
37 // This structure is used to store jpeg file sections in memory.
38 struct Section_t {
39 uchar * Data;
40 int Type;
41 unsigned Size;
42 };
43
44 struct TagTable_t {
45 unsigned short Tag;
46 const char*const Desc;
47 };
48
49private:
50 static const int MAX_SECTIONS=20;
51 static const unsigned int PSEUDO_IMAGE_MARKER=0x123;
52 Section_t Sections[MAX_SECTIONS];
53
54 QString CameraMake;
55 QString CameraModel;
56 QString DateTime;
57 int Orientation;
58 int Height, Width;
59 int ExifImageLength, ExifImageWidth;
60 int IsColor;
61 int Process;
62 int FlashUsed;
63 float FocalLength;
64 float ExposureTime;
65 float ApertureFNumber;
66 float Distance;
67 int Whitebalance;
68 int MeteringMode;
69 float CCDWidth;
70 float ExposureBias;
71 int ExposureProgram;
72 int ISOequivalent;
73 int CompressionLevel;
74 QString UserComment;
75 QString Comment;
76 QImage Thumbnail;
77
78 unsigned char * LastExifRefd;
79 int ExifSettingsLength;
80 double FocalplaneXRes;
81 double FocalplaneUnits;
82 int MotorolaOrder;
83 int SectionsRead;
84
85 int ReadJpegSections (QFile & infile, ReadMode_t ReadMode);
86 void DiscardData(void);
87 int Get16u(void * Short);
88 int Get32s(void * Long);
89 unsigned Get32u(void * Long);
90 double ConvertAnyFormat(void * ValuePtr, int Format);
91 void ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBase, unsigned ExifLength);
92 void process_COM (const uchar * Data, int length);
93 void process_SOFn (const uchar * Data, int marker);
94 int Get16m(const void * Short);
95 void process_EXIF(unsigned char * CharBuf, unsigned int length);
96 int Exif2tm(struct ::tm * timeptr, char * ExifTime);
97
98public:
99 //! Contructor for initialising
100 ExifData();
101 //! destructor
102 virtual ~ExifData();
103 //! scan a given file
104 /*!
105 * try to scan the EXIF data of a image file
106 * \param aFile the file to scan
107 * \return true if success, otherwise false
108 */
109 bool scan(const QString &aFile);
110 QString getCameraMake() { return CameraMake; }
111 QString getCameraModel() { return CameraModel; }
112 QString getDateTime() { return DateTime; }
113 int getOrientation() { return Orientation; }
114 int getHeight() { return Height; }
115 int getWidth() { return Width; }
116 int getIsColor() { return IsColor; }
117 int getProcess() { return Process; }
118 int getFlashUsed() { return FlashUsed; }
119 float getFocalLength() { return FocalLength; }
120 float getExposureTime() { return ExposureTime; }
121 float getApertureFNumber() { return ApertureFNumber; }
122 float getDistance() { return Distance; }
123 int getWhitebalance() { return Whitebalance; }
124 int getMeteringMode() { return MeteringMode; }
125 float getCCDWidth() { return CCDWidth; }
126 float getExposureBias() { return ExposureBias; }
127 int getExposureProgram() { return ExposureProgram; }
128 int getISOequivalent() { return ISOequivalent; }
129 int getCompressionLevel() { return CompressionLevel; }
130 QString getUserComment() { return UserComment; }
131 QString getComment() { return Comment; }
132 QImage getThumbnail();
133 bool isThumbnailSane();
134 bool isNullThumbnail() { return !isThumbnailSane(); }
135};
136
137}
138}
139#endif