Merge branch 'dev' into spot-removal-tool
This commit is contained in:
@@ -26,7 +26,6 @@
|
||||
#include "imagedimensions.h"
|
||||
#include "LUT.h"
|
||||
#include "coord2d.h"
|
||||
#include "procparams.h"
|
||||
#include "color.h"
|
||||
#include "../rtgui/threadutils.h"
|
||||
|
||||
@@ -43,12 +42,21 @@
|
||||
namespace rtengine
|
||||
{
|
||||
|
||||
namespace procparams
|
||||
{
|
||||
|
||||
struct CoarseTransformParams;
|
||||
|
||||
}
|
||||
|
||||
class ProgressListener;
|
||||
class Color;
|
||||
|
||||
extern const char sImage8[];
|
||||
extern const char sImage16[];
|
||||
extern const char sImagefloat[];
|
||||
int getCoarseBitMask( const procparams::CoarseTransformParams &coarse);
|
||||
class ProgressListener;
|
||||
class Color;
|
||||
|
||||
int getCoarseBitMask(const procparams::CoarseTransformParams& coarse);
|
||||
|
||||
enum TypeInterpolation { TI_Nearest, TI_Bilinear };
|
||||
|
||||
@@ -82,22 +90,18 @@ public:
|
||||
// Read the raw dump of the data
|
||||
void readData (FILE *fh) {}
|
||||
// Write a raw dump of the data
|
||||
void writeData (FILE *fh) {}
|
||||
void writeData (FILE *fh) const {}
|
||||
|
||||
virtual void normalizeInt (int srcMinVal, int srcMaxVal) {};
|
||||
virtual void normalizeFloat (float srcMinVal, float srcMaxVal) {};
|
||||
virtual void computeHistogramAutoWB (double &avg_r, double &avg_g, double &avg_b, int &n, LUTu &histogram, int compression) {}
|
||||
virtual void computeHistogramAutoWB (double &avg_r, double &avg_g, double &avg_b, int &n, LUTu &histogram, int compression) const {}
|
||||
virtual void getSpotWBData (double &reds, double &greens, double &blues, int &rn, int &gn, int &bn,
|
||||
std::vector<Coord2D> &red, std::vector<Coord2D> &green, std::vector<Coord2D> &blue,
|
||||
int tran) {}
|
||||
virtual void getAutoWBMultipliers (double &rm, double &gm, double &bm)
|
||||
int tran) const {}
|
||||
virtual void getAutoWBMultipliers (double &rm, double &gm, double &bm) const
|
||||
{
|
||||
rm = gm = bm = 1.0;
|
||||
}
|
||||
virtual const char* getType () const
|
||||
{
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -119,13 +123,18 @@ inline void ImageDatas::convertTo(unsigned char src, unsigned short& dst) const
|
||||
template<>
|
||||
inline void ImageDatas::convertTo(float src, unsigned char& dst) const
|
||||
{
|
||||
dst = uint16ToUint8Rounded(src);
|
||||
dst = uint16ToUint8Rounded(CLIP(src));
|
||||
}
|
||||
template<>
|
||||
inline void ImageDatas::convertTo(unsigned char src, float& dst) const
|
||||
{
|
||||
dst = src * 257;
|
||||
}
|
||||
template<>
|
||||
inline void ImageDatas::convertTo(float src, float& dst) const
|
||||
{
|
||||
dst = std::isnan(src) ? 0.f : src;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Planar order classes
|
||||
@@ -138,7 +147,7 @@ protected:
|
||||
AlignedBuffer<T*> ab;
|
||||
public:
|
||||
#if CHECK_BOUNDS
|
||||
int width_, height_;
|
||||
size_t width_, height_;
|
||||
#endif
|
||||
T** ptrs;
|
||||
|
||||
@@ -148,7 +157,7 @@ public:
|
||||
PlanarPtr() : ptrs (nullptr) {}
|
||||
#endif
|
||||
|
||||
bool resize(int newSize)
|
||||
bool resize(size_t newSize)
|
||||
{
|
||||
if (ab.resize(newSize)) {
|
||||
ptrs = ab.data;
|
||||
@@ -166,7 +175,7 @@ public:
|
||||
ptrs = tmpsPtrs;
|
||||
|
||||
#if CHECK_BOUNDS
|
||||
int tmp = other.width_;
|
||||
size_t tmp = other.width_;
|
||||
other.width_ = width_;
|
||||
width_ = tmp;
|
||||
tmp = other.height_;
|
||||
@@ -175,7 +184,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
T*& operator() (unsigned row)
|
||||
T*& operator() (size_t row)
|
||||
{
|
||||
#if CHECK_BOUNDS
|
||||
assert (row < height_);
|
||||
@@ -183,7 +192,7 @@ public:
|
||||
return ptrs[row];
|
||||
}
|
||||
// Will send back the start of a row, starting with a red, green or blue value
|
||||
T* operator() (unsigned row) const
|
||||
T* operator() (size_t row) const
|
||||
{
|
||||
#if CHECK_BOUNDS
|
||||
assert (row < height_);
|
||||
@@ -191,14 +200,14 @@ public:
|
||||
return ptrs[row];
|
||||
}
|
||||
// Will send back a value at a given row, col position
|
||||
T& operator() (unsigned row, unsigned col)
|
||||
T& operator() (size_t row, size_t col)
|
||||
{
|
||||
#if CHECK_BOUNDS
|
||||
assert (row < height_ && col < width_);
|
||||
#endif
|
||||
return ptrs[row][col];
|
||||
}
|
||||
const T operator() (unsigned row, unsigned col) const
|
||||
const T operator() (size_t row, size_t col) const
|
||||
{
|
||||
#if CHECK_BOUNDS
|
||||
assert (row < height_ && col < width_);
|
||||
@@ -214,7 +223,7 @@ class PlanarWhateverData : virtual public ImageDatas
|
||||
private:
|
||||
AlignedBuffer<T> abData;
|
||||
|
||||
int rowstride; // Plan size, in bytes (all padding bytes included)
|
||||
size_t rowstride; // Plan size, in bytes (all padding bytes included)
|
||||
|
||||
public:
|
||||
T* data;
|
||||
@@ -227,7 +236,7 @@ public:
|
||||
}
|
||||
|
||||
// Send back the row stride. WARNING: unit = byte, not element!
|
||||
int getRowStride ()
|
||||
size_t getRowStride () const
|
||||
{
|
||||
return rowstride;
|
||||
}
|
||||
@@ -256,9 +265,8 @@ public:
|
||||
|
||||
/* If any of the required allocation fails, "width" and "height" are set to -1, and all remaining buffer are freed
|
||||
* Can be safely used to reallocate an existing image */
|
||||
void allocate (int W, int H)
|
||||
void allocate (int W, int H) override
|
||||
{
|
||||
|
||||
if (W == width && H == height) {
|
||||
return;
|
||||
}
|
||||
@@ -311,7 +319,7 @@ public:
|
||||
}
|
||||
|
||||
/** Copy the data to another PlanarWhateverData */
|
||||
void copyData(PlanarWhateverData<T> *dest)
|
||||
void copyData(PlanarWhateverData<T> *dest) const
|
||||
{
|
||||
assert (dest != NULL);
|
||||
// Make sure that the size is the same, reallocate if necessary
|
||||
@@ -343,7 +351,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void rotate (int deg)
|
||||
void rotate (int deg) override
|
||||
{
|
||||
|
||||
if (deg == 90) {
|
||||
@@ -401,7 +409,7 @@ public:
|
||||
}
|
||||
|
||||
template <class IC>
|
||||
void resizeImgTo (int nw, int nh, TypeInterpolation interp, PlanarWhateverData<IC> *imgPtr)
|
||||
void resizeImgTo (int nw, int nh, TypeInterpolation interp, PlanarWhateverData<IC> *imgPtr) const
|
||||
{
|
||||
//printf("resizeImgTo: resizing %s image data (%d x %d) to %s (%d x %d)\n", getType(), width, height, imgPtr->getType(), imgPtr->width, imgPtr->height);
|
||||
if (width == nw && height == nh) {
|
||||
@@ -462,7 +470,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void hflip ()
|
||||
void hflip () override
|
||||
{
|
||||
int width2 = width / 2;
|
||||
|
||||
@@ -486,7 +494,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
void vflip ()
|
||||
void vflip () override
|
||||
{
|
||||
|
||||
int height2 = height / 2;
|
||||
@@ -511,17 +519,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
void calcHist(unsigned int *hist16)
|
||||
{
|
||||
for (int row = 0; row < height; row++)
|
||||
for (int col = 0; col < width; col++) {
|
||||
unsigned short idx;
|
||||
convertTo(v(row, col), idx);
|
||||
hist16[idx]++;
|
||||
}
|
||||
}
|
||||
|
||||
void transformPixel (int x, int y, int tran, int& tx, int& ty)
|
||||
void transformPixel (int x, int y, int tran, int& tx, int& ty) const
|
||||
{
|
||||
|
||||
if (!tran) {
|
||||
@@ -564,7 +562,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void getPipetteData (T &value, int posX, int posY, int squareSize, int tran)
|
||||
void getPipetteData (T &value, int posX, int posY, int squareSize, int tran) const
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
@@ -585,20 +583,28 @@ public:
|
||||
value = n ? T(accumulator / float(n)) : T(0);
|
||||
}
|
||||
|
||||
void readData (FILE *f)
|
||||
void readData (FILE *f)
|
||||
{
|
||||
for (int i = 0; i < height; i++) {
|
||||
fread (v(i), sizeof(T), width, f);
|
||||
}
|
||||
}
|
||||
|
||||
void writeData (FILE *f)
|
||||
void writeData (FILE *f) const
|
||||
{
|
||||
for (int i = 0; i < height; i++) {
|
||||
fwrite (v(i), sizeof(T), width, f);
|
||||
}
|
||||
}
|
||||
|
||||
void fill (T value) {
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) {
|
||||
v(i, j) = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -609,8 +615,8 @@ class PlanarRGBData : virtual public ImageDatas
|
||||
private:
|
||||
AlignedBuffer<T> abData;
|
||||
|
||||
int rowstride; // Plan size, in bytes (all padding bytes included)
|
||||
int planestride; // Row length, in bytes (padding bytes included)
|
||||
size_t rowstride; // Plan size, in bytes (all padding bytes included)
|
||||
size_t planestride; // Row length, in bytes (padding bytes included)
|
||||
protected:
|
||||
T* data;
|
||||
|
||||
@@ -620,18 +626,18 @@ public:
|
||||
PlanarPtr<T> b;
|
||||
|
||||
PlanarRGBData() : rowstride(0), planestride(0), data (nullptr) {}
|
||||
PlanarRGBData(int w, int h) : rowstride(0), planestride(0), data (nullptr)
|
||||
PlanarRGBData(size_t w, size_t h) : rowstride(0), planestride(0), data (nullptr)
|
||||
{
|
||||
allocate(w, h);
|
||||
}
|
||||
|
||||
// Send back the row stride. WARNING: unit = byte, not element!
|
||||
int getRowStride ()
|
||||
size_t getRowStride () const
|
||||
{
|
||||
return rowstride;
|
||||
}
|
||||
// Send back the plane stride. WARNING: unit = byte, not element!
|
||||
int getPlaneStride ()
|
||||
size_t getPlaneStride () const
|
||||
{
|
||||
return planestride;
|
||||
}
|
||||
@@ -666,7 +672,7 @@ public:
|
||||
|
||||
/* If any of the required allocation fails, "width" and "height" are set to -1, and all remaining buffer are freed
|
||||
* Can be safely used to reallocate an existing image */
|
||||
void allocate (int W, int H)
|
||||
void allocate (int W, int H) override
|
||||
{
|
||||
|
||||
if (W == width && H == height) {
|
||||
@@ -728,7 +734,7 @@ public:
|
||||
char *bluestart = (char*)(data) + 2 * planestride;
|
||||
|
||||
for (int i = 0; i < height; ++i) {
|
||||
int k = i * rowstride;
|
||||
size_t k = i * rowstride;
|
||||
r(i) = (T*)(redstart + k);
|
||||
g(i) = (T*)(greenstart + k);
|
||||
b(i) = (T*)(bluestart + k);
|
||||
@@ -736,7 +742,7 @@ public:
|
||||
}
|
||||
|
||||
/** Copy the data to another PlanarRGBData */
|
||||
void copyData(PlanarRGBData<T> *dest)
|
||||
void copyData(PlanarRGBData<T> *dest) const
|
||||
{
|
||||
assert (dest != nullptr);
|
||||
// Make sure that the size is the same, reallocate if necessary
|
||||
@@ -773,7 +779,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void rotate (int deg)
|
||||
void rotate (int deg) override
|
||||
{
|
||||
|
||||
if (deg == 90) {
|
||||
@@ -843,7 +849,7 @@ public:
|
||||
}
|
||||
|
||||
template <class IC>
|
||||
void resizeImgTo (int nw, int nh, TypeInterpolation interp, IC *imgPtr)
|
||||
void resizeImgTo (int nw, int nh, TypeInterpolation interp, IC *imgPtr) const
|
||||
{
|
||||
//printf("resizeImgTo: resizing %s image data (%d x %d) to %s (%d x %d)\n", getType(), width, height, imgPtr->getType(), imgPtr->width, imgPtr->height);
|
||||
if (width == nw && height == nh) {
|
||||
@@ -892,15 +898,15 @@ public:
|
||||
// This case should never occur!
|
||||
for (int i = 0; i < nh; i++) {
|
||||
for (int j = 0; j < nw; j++) {
|
||||
r(i, j) = 0;
|
||||
g(i, j) = 0;
|
||||
b(i, j) = 0;
|
||||
imgPtr->r(i, j) = 0;
|
||||
imgPtr->g(i, j) = 0;
|
||||
imgPtr->b(i, j) = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hflip ()
|
||||
void hflip () override
|
||||
{
|
||||
int width2 = width / 2;
|
||||
|
||||
@@ -932,7 +938,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
void vflip ()
|
||||
void vflip () override
|
||||
{
|
||||
|
||||
int height2 = height / 2;
|
||||
@@ -965,7 +971,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
void calcGrayscaleHist(unsigned int *hist16)
|
||||
void calcGrayscaleHist(unsigned int *hist16) const
|
||||
{
|
||||
for (int row = 0; row < height; row++)
|
||||
for (int col = 0; col < width; col++) {
|
||||
@@ -979,7 +985,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void computeAutoHistogram (LUTu & histogram, int& histcompr)
|
||||
void computeAutoHistogram (LUTu & histogram, int& histcompr) const
|
||||
{
|
||||
histcompr = 3;
|
||||
|
||||
@@ -998,7 +1004,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void computeHistogramAutoWB (double &avg_r, double &avg_g, double &avg_b, int &n, LUTu &histogram, const int compression)
|
||||
void computeHistogramAutoWB (double &avg_r, double &avg_g, double &avg_b, int &n, LUTu &histogram, const int compression) const override
|
||||
{
|
||||
histogram.clear();
|
||||
avg_r = avg_g = avg_b = 0.;
|
||||
@@ -1030,7 +1036,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void getAutoWBMultipliers (double &rm, double &gm, double &bm)
|
||||
void getAutoWBMultipliers (double &rm, double &gm, double &bm) const override
|
||||
{
|
||||
|
||||
double avg_r = 0.;
|
||||
@@ -1061,7 +1067,7 @@ public:
|
||||
bm = avg_b / double(n);
|
||||
}
|
||||
|
||||
void transformPixel (int x, int y, int tran, int& tx, int& ty)
|
||||
void transformPixel (int x, int y, int tran, int& tx, int& ty) const
|
||||
{
|
||||
|
||||
if (!tran) {
|
||||
@@ -1104,9 +1110,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void getSpotWBData (double &reds, double &greens, double &blues, int &rn, int &gn, int &bn,
|
||||
void getSpotWBData (double &reds, double &greens, double &blues, int &rn, int &gn, int &bn,
|
||||
std::vector<Coord2D> &red, std::vector<Coord2D> &green, std::vector<Coord2D> &blue,
|
||||
int tran)
|
||||
int tran) const override
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
@@ -1143,7 +1149,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void getPipetteData (T &valueR, T &valueG, T &valueB, int posX, int posY, int squareSize, int tran)
|
||||
void getPipetteData (T &valueR, T &valueG, T &valueB, int posX, int posY, int squareSize, int tran) const
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
@@ -1170,22 +1176,28 @@ public:
|
||||
valueB = n ? T(accumulatorB / float(n)) : T(0);
|
||||
}
|
||||
|
||||
void readData (FILE *f)
|
||||
void readData (FILE *f)
|
||||
{
|
||||
for (int i = 0; i < height; i++) {
|
||||
fread (r(i), sizeof(T), width, f);
|
||||
if (fread(r(i), sizeof(T), width, f) < static_cast<size_t>(width)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < height; i++) {
|
||||
fread (g(i), sizeof(T), width, f);
|
||||
if (fread(g(i), sizeof(T), width, f) < static_cast<size_t>(width)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < height; i++) {
|
||||
fread (b(i), sizeof(T), width, f);
|
||||
if (fread(b(i), sizeof(T), width, f) < static_cast<size_t>(width)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void writeData (FILE *f)
|
||||
void writeData (FILE *f) const
|
||||
{
|
||||
for (int i = 0; i < height; i++) {
|
||||
fwrite (r(i), sizeof(T), width, f);
|
||||
@@ -1211,10 +1223,10 @@ class ChunkyPtr
|
||||
{
|
||||
private:
|
||||
T* ptr;
|
||||
int width;
|
||||
ssize_t width;
|
||||
public:
|
||||
#if CHECK_BOUNDS
|
||||
int width_, height_;
|
||||
size_t width_, height_;
|
||||
#endif
|
||||
|
||||
#if CHECK_BOUNDS
|
||||
@@ -1222,7 +1234,7 @@ public:
|
||||
#else
|
||||
ChunkyPtr() : ptr (nullptr), width(-1) {}
|
||||
#endif
|
||||
void init(T* base, int w = -1)
|
||||
void init(T* base, ssize_t w = -1)
|
||||
{
|
||||
ptr = base;
|
||||
width = w;
|
||||
@@ -1233,12 +1245,12 @@ public:
|
||||
other.ptr = ptr;
|
||||
ptr = tmpsPtr;
|
||||
|
||||
int tmpWidth = other.width;
|
||||
ssize_t tmpWidth = other.width;
|
||||
other.width = width;
|
||||
width = tmpWidth;
|
||||
|
||||
#if CHECK_BOUNDS
|
||||
int tmp = other.width_;
|
||||
size_t tmp = other.width_;
|
||||
other.width_ = width_;
|
||||
width_ = tmp;
|
||||
tmp = other.height_;
|
||||
@@ -1249,7 +1261,7 @@ public:
|
||||
}
|
||||
|
||||
// Will send back the start of a row, starting with a red, green or blue value
|
||||
T* operator() (unsigned row) const
|
||||
T* operator() (size_t row) const
|
||||
{
|
||||
#if CHECK_BOUNDS
|
||||
assert (row < height_);
|
||||
@@ -1257,14 +1269,14 @@ public:
|
||||
return &ptr[3 * (row * width)];
|
||||
}
|
||||
// Will send back a value at a given row, col position
|
||||
T& operator() (unsigned row, unsigned col)
|
||||
T& operator() (size_t row, size_t col)
|
||||
{
|
||||
#if CHECK_BOUNDS
|
||||
assert (row < height_ && col < width_);
|
||||
#endif
|
||||
return ptr[3 * (row * width + col)];
|
||||
}
|
||||
const T operator() (unsigned row, unsigned col) const
|
||||
const T operator() (size_t row, size_t col) const
|
||||
{
|
||||
#if CHECK_BOUNDS
|
||||
assert (row < height_ && col < width_);
|
||||
@@ -1328,7 +1340,7 @@ public:
|
||||
* If any of the required allocation fails, "width" and "height" are set to -1, and all remaining buffer are freed
|
||||
* Can be safely used to reallocate an existing image or to free up it's memory with "allocate (0,0);"
|
||||
*/
|
||||
void allocate (int W, int H)
|
||||
void allocate (int W, int H) override
|
||||
{
|
||||
|
||||
if (W == width && H == height) {
|
||||
@@ -1346,7 +1358,7 @@ public:
|
||||
b.height_ = height;
|
||||
#endif
|
||||
|
||||
abData.resize(width * height * 3u);
|
||||
abData.resize((size_t)width * (size_t)height * (size_t)3);
|
||||
|
||||
if (!abData.isEmpty()) {
|
||||
data = abData.data;
|
||||
@@ -1368,7 +1380,7 @@ public:
|
||||
}
|
||||
|
||||
/** Copy the data to another ChunkyRGBData */
|
||||
void copyData(ChunkyRGBData<T> *dest)
|
||||
void copyData(ChunkyRGBData<T> *dest) const
|
||||
{
|
||||
assert (dest != nullptr);
|
||||
// Make sure that the size is the same, reallocate if necessary
|
||||
@@ -1399,7 +1411,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void rotate (int deg)
|
||||
void rotate (int deg) override
|
||||
{
|
||||
|
||||
if (deg == 90) {
|
||||
@@ -1461,7 +1473,7 @@ public:
|
||||
}
|
||||
|
||||
template <class IC>
|
||||
void resizeImgTo (int nw, int nh, TypeInterpolation interp, IC *imgPtr)
|
||||
void resizeImgTo (int nw, int nh, TypeInterpolation interp, IC *imgPtr) const
|
||||
{
|
||||
//printf("resizeImgTo: resizing %s image data (%d x %d) to %s (%d x %d)\n", getType(), width, height, imgPtr->getType(), imgPtr->width, imgPtr->height);
|
||||
if (width == nw && height == nh) {
|
||||
@@ -1525,15 +1537,15 @@ public:
|
||||
// This case should never occur!
|
||||
for (int i = 0; i < nh; i++) {
|
||||
for (int j = 0; j < nw; j++) {
|
||||
r(i, j) = 0;
|
||||
g(i, j) = 0;
|
||||
b(i, j) = 0;
|
||||
imgPtr->r(i, j) = 0;
|
||||
imgPtr->g(i, j) = 0;
|
||||
imgPtr->b(i, j) = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hflip ()
|
||||
void hflip () override
|
||||
{
|
||||
int width2 = width / 2;
|
||||
|
||||
@@ -1569,7 +1581,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void vflip ()
|
||||
void vflip () override
|
||||
{
|
||||
|
||||
AlignedBuffer<T> lBuffer(3 * width);
|
||||
@@ -1585,7 +1597,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void calcGrayscaleHist(unsigned int *hist16)
|
||||
void calcGrayscaleHist(unsigned int *hist16) const
|
||||
{
|
||||
for (int row = 0; row < height; row++)
|
||||
for (int col = 0; col < width; col++) {
|
||||
@@ -1599,7 +1611,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void computeAutoHistogram (LUTu & histogram, int& histcompr)
|
||||
void computeAutoHistogram (LUTu & histogram, int& histcompr) const
|
||||
{
|
||||
histcompr = 3;
|
||||
|
||||
@@ -1618,7 +1630,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void computeHistogramAutoWB (double &avg_r, double &avg_g, double &avg_b, int &n, LUTu &histogram, const int compression)
|
||||
void computeHistogramAutoWB (double &avg_r, double &avg_g, double &avg_b, int &n, LUTu &histogram, const int compression) const override
|
||||
{
|
||||
histogram.clear();
|
||||
avg_r = avg_g = avg_b = 0.;
|
||||
@@ -1650,7 +1662,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void getAutoWBMultipliers (double &rm, double &gm, double &bm)
|
||||
void getAutoWBMultipliers (double &rm, double &gm, double &bm) const override
|
||||
{
|
||||
|
||||
double avg_r = 0.;
|
||||
@@ -1681,7 +1693,7 @@ public:
|
||||
bm = avg_b / double(n);
|
||||
}
|
||||
|
||||
void transformPixel (int x, int y, int tran, int& tx, int& ty)
|
||||
void transformPixel (int x, int y, int tran, int& tx, int& ty) const
|
||||
{
|
||||
|
||||
if (!tran) {
|
||||
@@ -1724,9 +1736,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void getSpotWBData (double &reds, double &greens, double &blues, int &rn, int &gn, int &bn,
|
||||
void getSpotWBData (double &reds, double &greens, double &blues, int &rn, int &gn, int &bn,
|
||||
std::vector<Coord2D> &red, std::vector<Coord2D> &green, std::vector<Coord2D> &blue,
|
||||
int tran)
|
||||
int tran) const override
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
@@ -1763,14 +1775,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void readData (FILE *f)
|
||||
void readData (FILE *f)
|
||||
{
|
||||
for (int i = 0; i < height; i++) {
|
||||
fread (r(i), sizeof(T), 3 * width, f);
|
||||
if (fread(r(i), sizeof(T), 3 * width, f) < 3 * static_cast<size_t>(width)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void writeData (FILE *f)
|
||||
void writeData (FILE *f) const
|
||||
{
|
||||
for (int i = 0; i < height; i++) {
|
||||
fwrite (r(i), sizeof(T), 3 * width, f);
|
||||
@@ -1791,30 +1805,31 @@ public:
|
||||
/** @brief Returns a mutex that can is useful in many situations. No image operations shuold be performed without locking this mutex.
|
||||
* @return The mutex */
|
||||
virtual MyMutex& getMutex () = 0;
|
||||
virtual cmsHPROFILE getProfile () = 0;
|
||||
virtual cmsHPROFILE getProfile () const = 0;
|
||||
/** @brief Returns the bits per pixel of the image.
|
||||
* @return The bits per pixel of the image */
|
||||
virtual int getBitsPerPixel () = 0;
|
||||
virtual int getBitsPerPixel () const = 0;
|
||||
/** @brief Saves the image to file. It autodetects the format (jpg, tif, png are supported).
|
||||
* @param fname is the name of the file
|
||||
@return the error code, 0 if none */
|
||||
virtual int saveToFile (Glib::ustring fname) = 0;
|
||||
virtual int saveToFile (const Glib::ustring &fname) const = 0;
|
||||
/** @brief Saves the image to file in a png format.
|
||||
* @param fname is the name of the file
|
||||
* @param compression is the amount of compression (0-6), -1 corresponds to the default
|
||||
* @param bps can be 8 or 16 depending on the bits per pixels the output file will have
|
||||
@return the error code, 0 if none */
|
||||
virtual int saveAsPNG (Glib::ustring fname, int bps = -1) = 0;
|
||||
virtual int saveAsPNG (const Glib::ustring &fname, int bps = -1) const = 0;
|
||||
/** @brief Saves the image to file in a jpg format.
|
||||
* @param fname is the name of the file
|
||||
* @param quality is the quality of the jpeg (0...100), set it to -1 to use default
|
||||
@return the error code, 0 if none */
|
||||
virtual int saveAsJPEG (Glib::ustring fname, int quality = 100, int subSamp = 3 ) = 0;
|
||||
virtual int saveAsJPEG (const Glib::ustring &fname, int quality = 100, int subSamp = 3 ) const = 0;
|
||||
/** @brief Saves the image to file in a tif format.
|
||||
* @param fname is the name of the file
|
||||
* @param bps can be 8 or 16 depending on the bits per pixels the output file will have
|
||||
* @param isFloat is true for saving float images. Will be ignored by file format not supporting float data
|
||||
@return the error code, 0 if none */
|
||||
virtual int saveAsTIFF (Glib::ustring fname, int bps = -1, bool uncompressed = false) = 0;
|
||||
virtual int saveAsTIFF (const Glib::ustring &fname, int bps = -1, bool isFloat = false, bool uncompressed = false) const = 0;
|
||||
/** @brief Sets the progress listener if you want to follow the progress of the image saving operations (optional).
|
||||
* @param pl is the pointer to the class implementing the ProgressListener interface */
|
||||
virtual void setSaveProgressListener (ProgressListener* pl) = 0;
|
||||
@@ -1827,14 +1842,14 @@ public:
|
||||
class IImagefloat : public IImage, public PlanarRGBData<float>
|
||||
{
|
||||
public:
|
||||
virtual ~IImagefloat() {}
|
||||
~IImagefloat() override {}
|
||||
};
|
||||
|
||||
/** @brief This class represents an image having a classical 8 bits/pixel representation */
|
||||
class IImage8 : public IImage, public ChunkyRGBData<unsigned char>
|
||||
{
|
||||
public:
|
||||
virtual ~IImage8() {}
|
||||
~IImage8() override {}
|
||||
};
|
||||
|
||||
/** @brief This class represents an image having a 16 bits/pixel planar representation.
|
||||
@@ -1842,7 +1857,7 @@ public:
|
||||
class IImage16 : public IImage, public PlanarRGBData<unsigned short>
|
||||
{
|
||||
public:
|
||||
virtual ~IImage16() {}
|
||||
~IImage16() override {}
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user