-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageData.h
More file actions
114 lines (87 loc) · 3.57 KB
/
ImageData.h
File metadata and controls
114 lines (87 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#ifndef IMAGEDATA_H
#define IMAGEDATA_H
#include <FreeImage.h>
#include <QString>
#include <QRect>
//Declare it here instead of adding the include
class ImageWindow;
class ImageData
{
public:
ImageData() {initClass();}
bool reallocate(int width, int height, int numChannels, int BPP);
virtual ~ImageData() {freeData();}
bool readImage(QString filename);
int getWidth() {return width; }
int getHeight() {return height;}
int getArea() {return width * height;}
int getNumChannels() {return numChannels;}
int getBPP() {return BPP;}
ushort *data;
double getMinValue() {return minValue;}
double getMaxValue() {return maxValue;}
int getMinIndex() {return minIndex;}
int getMaxIndex() {return maxIndex;}
#define MULTI_CHANNEL_INDEX ((x + y * width) * numChannels + channel)
inline double getPixel(int x, int y, int channel) {return data[MULTI_CHANNEL_INDEX];}
inline double getPixel(int index, int channel) {return data[index * numChannels + channel];}
void feedData(FIBITMAP *image, FREE_IMAGE_TYPE imgType);
void feedData(ushort *image);
void feedDataReverse(ushort *image);
void recalcMinMax();
bool doWhiteBalance(QRect &Area);
bool resetWhiteBalance();
bool getEXIFMake(QString &make) {make = EXIFMake; return haveEXIFMake;}
bool getEXIFFirmware(QString &firmware) {firmware = EXIFFirmware; return haveEXIFFirmware;}
bool getEXIFISO(int &ISO) {ISO = EXIFISO; return haveEXIFISO;}
bool getEXIFShutter(double &shutterms) {shutterms = EXIFShutter; return haveEXIFShutter;}
bool getEXIFAperture(double &aperture) {aperture = EXIFAperture; return haveEXIFAperture;}
bool getEXIFDate(QString &date) {date = EXIFDate; return haveEXIFDate;}
bool getEXIFEV(double &EV);
bool getEXIFTemperatures(double &sensor, double &dsp, double &bat, double &pmic);
//This is a pointer to the ImageWindow responsible for displaying this image.
//If you don't want auto-reallocate and auto-repaint, then set it to nullptr.
//You can call ImageWindow::SignalNewData to do this manually.
ImageWindow *painter;
protected:
int width, height;
int numChannels;
int BPP;
long memSizeBytes;
double minValue, maxValue;
int minIndex, maxIndex;
void checkMinMax(ushort pixValue, int index);
void initClass();
void resetMinMax() {minIndex = 0; maxIndex = 0; minValue = 65535; maxValue = 0;}
inline void setPixel(int index, ushort src) {data[index] = src;}
inline void setPixel(int x, int y, int channel, ushort src) {data[MULTI_CHANNEL_INDEX] = src;}
virtual void allocateData();
virtual void freeData();
bool readRAW(QString filename);
//For grey scale images, we assume that we have a bayer array and thus we are looking
//to equate the grey values within a 2x2 pixel area.
bool doWhiteBalanceGrey(QRect &greyArea);
double greyGains[2][2];
//For color, we just calculate gains for each color.
bool doWhiteBalanceColor(QRect &colorArea);
double colorGains[3];
bool resetWhiteBalanceGrey();
bool resetWhiteBalanceColor();
void retrieveEXIFTags(FIBITMAP *img);
void resetEXIFStatus();
bool haveEXIFMake;
QString EXIFMake;
bool haveEXIFFirmware;
QString EXIFFirmware;
bool haveEXIFISO;
int EXIFISO;
bool haveEXIFShutter;
double EXIFShutter;
bool haveEXIFAperture;
double EXIFAperture;
bool haveEXIFDate;
QString EXIFDate;
bool haveEXIFTemperatures;
double EXIFSensorTemp, EXIFDSPTemp, EXIFBatTemp, EXIFPMICTemp;
};
#endif // IMAGEDATA_H