| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "ExifParse.h" |
| 4 |
#include "IptcParse.h" |
| 5 |
|
| 6 |
#include <stdio.h> |
| 7 |
|
| 8 |
//-------------------------------------------------------------------------- |
| 9 |
// JPEG markers consist of one or more 0xFF bytes, followed by a marker |
| 10 |
// code byte (which is not an FF). Here are the marker codes of interest |
| 11 |
// in this application. |
| 12 |
//-------------------------------------------------------------------------- |
| 13 |
|
| 14 |
#define M_SOF0 0xC0 // Start Of Frame N |
| 15 |
#define M_SOF1 0xC1 // N indicates which compression process |
| 16 |
#define M_SOF2 0xC2 // Only SOF0-SOF2 are now in common use |
| 17 |
#define M_SOF3 0xC3 |
| 18 |
#define M_SOF5 0xC5 // NB: codes C4 and CC are NOT SOF markers |
| 19 |
#define M_SOF6 0xC6 |
| 20 |
#define M_SOF7 0xC7 |
| 21 |
#define M_SOF9 0xC9 |
| 22 |
#define M_SOF10 0xCA |
| 23 |
#define M_SOF11 0xCB |
| 24 |
#define M_SOF13 0xCD |
| 25 |
#define M_SOF14 0xCE |
| 26 |
#define M_SOF15 0xCF |
| 27 |
#define M_SOI 0xD8 // Start Of Image (beginning of datastream) |
| 28 |
#define M_EOI 0xD9 // End Of Image (end of datastream) |
| 29 |
#define M_SOS 0xDA // Start Of Scan (begins compressed data) |
| 30 |
#define M_JFIF 0xE0 // Jfif marker |
| 31 |
#define M_EXIF 0xE1 // Exif marker |
| 32 |
#define M_COM 0xFE // COMment |
| 33 |
#define M_DQT 0xDB |
| 34 |
#define M_DHT 0xC4 |
| 35 |
#define M_DRI 0xDD |
| 36 |
#define M_IPTC 0xED // IPTC marker |
| 37 |
|
| 38 |
namespace XFILE |
| 39 |
{ |
| 40 |
class CFile; |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
class CJpegParse |
| 45 |
{ |
| 46 |
public: |
| 47 |
CJpegParse(); |
| 48 |
~CJpegParse(void) = default; |
| 49 |
bool Process(const char *picFileName); |
| 50 |
const ExifInfo_t* GetExifInfo() const { return &m_ExifInfo; } |
| 51 |
const IPTCInfo_t* GetIptcInfo() const { return &m_IPTCInfo; } |
| 52 |
|
| 53 |
private: |
| 54 |
bool ExtractInfo(XFILE::CFile& infile); |
| 55 |
bool GetSection(XFILE::CFile& infile, const unsigned short sectionLength); |
| 56 |
void ReleaseSection(void); |
| 57 |
void ProcessSOFn(void); |
| 58 |
|
| 59 |
unsigned char* m_SectionBuffer; |
| 60 |
ExifInfo_t m_ExifInfo; |
| 61 |
IPTCInfo_t m_IPTCInfo; |
| 62 |
}; |
| 63 |
|