Back to index

scribus-ng  1.3.4.dfsg+svn20071115
exif.h
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #ifndef __EXIF_H__
00008 #define __EXIF_H__
00009 
00014 #include <stdio.h>
00015 #include <stdlib.h>
00016 #include <math.h>
00017 #include <time.h>
00018 
00019 #include "qstring.h"
00020 #include "qfile.h"
00021 #include "qimage.h"
00022 
00023 typedef enum {
00024     READ_EXIF = 1,
00025     READ_IMAGE = 2,
00026     READ_ALL = 3
00027 }ReadMode_t;
00028 
00029 //--------------------------------------------------------------------------
00030 // This structure is used to store jpeg file sections in memory.
00031 typedef struct {
00032     uchar *  Data;
00033     int      Type;
00034     unsigned Size;
00035 }Section_t;
00036 
00037 typedef unsigned char uchar;
00038 
00039 class TagTable 
00040 {
00041 public:
00042        TagTable(unsigned short t, const char* d) : Tag(t), Desc(d) {}
00043     unsigned short Tag;
00044     const char*const Desc;   
00045 };
00046 
00047 #define MAX_SECTIONS 60
00048 #define PSEUDO_IMAGE_MARKER 0x123; // Extra value.
00049 
00050 class ExifData {
00051     Section_t Sections[MAX_SECTIONS];
00052     QString CameraMake;
00053     QString CameraModel;
00054     QString DateTime;
00055     int   Orientation;
00056     int   Height, Width;
00057     int   ExifImageLength, ExifImageWidth;
00058     int   IsColor;
00059     int   Process;
00060     int   FlashUsed;
00061     float FocalLength;
00062     float ExposureTime;
00063     float ApertureFNumber;
00064     float Distance;
00065     int    Whitebalance;
00066     int    MeteringMode;
00067     float CCDWidth;
00068     float ExposureBias;
00069     int   ExposureProgram;
00070     int   ISOequivalent;
00071     int   CompressionLevel;
00072     QString UserComment;
00073     QString Comment;
00074     QImage Thumbnail;
00075 
00076     int ReadJpegSections (QFile & infile, ReadMode_t ReadMode);
00077     void DiscardData(void);
00078     int Get16u(void * Short);
00079     int Get32s(void * Long);
00080     unsigned Get32u(void * Long);
00081     double ConvertAnyFormat(void * ValuePtr, int Format);
00082     void ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBase, unsigned ExifLength);
00083     void process_COM (const uchar * Data, int length);
00084     void process_SOFn (const uchar * Data, int marker);
00085     int Get16m(const void * Short);
00086     void process_EXIF(unsigned char * CharBuf, unsigned int length);
00087     int Exif2tm(struct tm * timeptr, char * ExifTime);
00088 
00089 public:
00090     ExifData();
00091     bool scan(const QString &);
00092     QString getCameraMake() { return CameraMake; }
00093     QString getCameraModel() { return CameraModel; }
00094     QString getDateTime() { return DateTime; }
00095     int getOrientation() { return Orientation; }
00096     int getHeight() { return Height; }
00097     int getWidth() { return Width; }
00098     int getIsColor() { return IsColor; }
00099     int getProcess() { return Process; }
00100     int getFlashUsed() { return FlashUsed; }
00101     float getFocalLength() { return FocalLength; }
00102     float getExposureTime() { return ExposureTime; }
00103     float getApertureFNumber() { return ApertureFNumber; }
00104     float getDistance() { return Distance; }
00105     int getWhitebalance() { return Whitebalance; }
00106     int getMeteringMode() { return MeteringMode; }
00107     float getCCDWidth() { return CCDWidth; }
00108     float getExposureBias() { return ExposureBias; }
00109     int getExposureProgram() { return ExposureProgram; }
00110     int getISOequivalent() { return ISOequivalent; }
00111     int getCompressionLevel() { return CompressionLevel; }
00112     QString getUserComment() { return UserComment; }
00113     QString getComment() { return Comment; }
00114     QImage getThumbnail();
00115     bool isThumbnailSane();
00116     bool isNullThumbnail() { return !isThumbnailSane(); }
00117        bool exifDataValid;
00118 };
00119 
00120 class FatalError {
00121     const char* ex;
00122 public:
00123     FatalError(const char* s) { ex = s; }
00124     void debug_print() const { qDebug("exception: "); }
00125 };
00126 
00127 extern TagTable ProcessTable[];
00128 
00129 //--------------------------------------------------------------------------
00130 // Define comment writing code, impelemented in setcomment.c
00131 extern int safe_copy_and_modify( const char * original_filename, const char * comment );
00132 
00133 #endif
00134