00001 #ifndef _OPIE_EXIF_H
00002 #define _OPIE_EXIF_H
00003
00004 #include <qt.h>
00005 #include <qstring.h>
00006 #include <qimage.h>
00007 #include <qfile.h>
00008
00009 #include <time.h>
00010
00011 namespace Opie { namespace MM {
00012
00013 #ifndef uchar
00014 typedef unsigned char uchar;
00015 #endif
00016
00017
00018
00019
00021
00028 class ExifData {
00029 public:
00030 enum ReadMode_t {
00031 READ_EXIF = 1,
00032 READ_IMAGE = 2,
00033 READ_ALL = 3
00034 };
00035
00036
00037
00038 struct Section_t {
00039 uchar * Data;
00040 int Type;
00041 unsigned Size;
00042 };
00043
00044 struct TagTable_t {
00045 unsigned short Tag;
00046 const char*const Desc;
00047 };
00048
00049 private:
00050 static const int MAX_SECTIONS=20;
00051 static const unsigned int PSEUDO_IMAGE_MARKER=0x123;
00052 Section_t Sections[MAX_SECTIONS];
00053
00054 QString CameraMake;
00055 QString CameraModel;
00056 QString DateTime;
00057 int Orientation;
00058 int Height, Width;
00059 int ExifImageLength, ExifImageWidth;
00060 int IsColor;
00061 int Process;
00062 int FlashUsed;
00063 float FocalLength;
00064 float ExposureTime;
00065 float ApertureFNumber;
00066 float Distance;
00067 int Whitebalance;
00068 int MeteringMode;
00069 float CCDWidth;
00070 float ExposureBias;
00071 int ExposureProgram;
00072 int ISOequivalent;
00073 int CompressionLevel;
00074 QString UserComment;
00075 QString Comment;
00076 QImage Thumbnail;
00077
00078 unsigned char * LastExifRefd;
00079 int ExifSettingsLength;
00080 double FocalplaneXRes;
00081 double FocalplaneUnits;
00082 int MotorolaOrder;
00083 int SectionsRead;
00084
00085 int ReadJpegSections (QFile & infile, ReadMode_t ReadMode);
00086 void DiscardData(void);
00087 int Get16u(void * Short);
00088 int Get32s(void * Long);
00089 unsigned Get32u(void * Long);
00090 double ConvertAnyFormat(void * ValuePtr, int Format);
00091 void ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBase, unsigned ExifLength);
00092 void process_COM (const uchar * Data, int length);
00093 void process_SOFn (const uchar * Data, int marker);
00094 int Get16m(const void * Short);
00095 void process_EXIF(unsigned char * CharBuf, unsigned int length);
00096 int Exif2tm(struct ::tm * timeptr, char * ExifTime);
00097
00098 public:
00100 ExifData();
00102 virtual ~ExifData();
00104
00109 bool scan(const QString &aFile);
00110 QString getCameraMake() { return CameraMake; }
00111 QString getCameraModel() { return CameraModel; }
00112 QString getDateTime() { return DateTime; }
00113 int getOrientation() { return Orientation; }
00114 int getHeight() { return Height; }
00115 int getWidth() { return Width; }
00116 int getIsColor() { return IsColor; }
00117 int getProcess() { return Process; }
00118 int getFlashUsed() { return FlashUsed; }
00119 float getFocalLength() { return FocalLength; }
00120 float getExposureTime() { return ExposureTime; }
00121 float getApertureFNumber() { return ApertureFNumber; }
00122 float getDistance() { return Distance; }
00123 int getWhitebalance() { return Whitebalance; }
00124 int getMeteringMode() { return MeteringMode; }
00125 float getCCDWidth() { return CCDWidth; }
00126 float getExposureBias() { return ExposureBias; }
00127 int getExposureProgram() { return ExposureProgram; }
00128 int getISOequivalent() { return ISOequivalent; }
00129 int getCompressionLevel() { return CompressionLevel; }
00130 QString getUserComment() { return UserComment; }
00131 QString getComment() { return Comment; }
00132 QImage getThumbnail();
00133 bool isThumbnailSane();
00134 bool isNullThumbnail() { return !isThumbnailSane(); }
00135
00136
00137 static QString color_mode_to_string( bool b );
00138 static QString compression_to_string( int level );
00139 static QString white_balance_string( int i );
00140 static QString metering_mode( int i);
00141 static QString exposure_program( int i );
00142 };
00143
00144 }
00145 }
00146 #endif