1 /*
2  *  This file is part of RawTherapee.
3  *
4  *  Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
5  *
6  *  RawTherapee is free software: you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation, either version 3 of the License, or
9  *  (at your option) any later version.
10  *
11  *  RawTherapee is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with RawTherapee.  If not, see <https://www.gnu.org/licenses/>.
18  */
19 #pragma once
20 
21 #include "colortemp.h"
22 #include "imagesource.h"
23 
24 namespace rtengine
25 {
26 
27 class ImageIO;
28 
29 namespace procparams
30 {
31 
32 class ProcParams;
33 
34 struct ToneCurveParams;
35 struct RAWParams;
36 struct ColorManagementParams;
37 
38 }
39 
40 class StdImageSource : public ImageSource
41 {
42 
43 protected:
44     ImageIO* img;
45     ColorTemp wb;
46     ProgressListener* plistener;
47     bool full;
48     int max[3];
49     bool rgbSourceModified;
50 
51     //void transformPixel             (int x, int y, int tran, int& tx, int& ty);
52     void getSampleFormat (const Glib::ustring &fname, IIOSampleFormat &sFormat, IIOSampleArrangement &sArrangement);
53 
54 public:
55     StdImageSource ();
56     ~StdImageSource () override;
57 
58     int         load        (const Glib::ustring &fname) override;
59     void        getImage    (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const procparams::ToneCurveParams &hrp, const procparams::RAWParams &raw) override;
getWB()60     ColorTemp   getWB       () const override
61     {
62         return wb;
63     }
64     void        getAutoWBMultipliers (double &rm, double &gm, double &bm) override;
65     ColorTemp   getSpotWB   (std::vector<Coord2D> &red, std::vector<Coord2D> &green, std::vector<Coord2D> &blue, int tran, double equal) override;
66 
getSensorType()67     eSensorType getSensorType() const override {return ST_NONE;}
isMono()68     bool isMono() const override {return false;}
69 
isWBProviderReady()70     bool        isWBProviderReady () override
71     {
72         return true;
73     };
74 
75     void        getAutoExpHistogram (LUTu &histogram, int& histcompr) override;
76 
getDefGain()77     double      getDefGain  () const override
78     {
79         return 0.0;
80     }
81 
82     void        getFullSize (int& w, int& h, int tr = TR_NONE) override;
83     void        getSize     (const PreviewProps &pp, int& w, int& h) override;
84 
getImageIO()85     ImageIO*    getImageIO   ()
86     {
87         return img;
88     }
getImageMatrices()89     ImageMatrices* getImageMatrices () override
90     {
91         return (ImageMatrices*)nullptr;
92     }
isRAW()93     bool        isRAW() const override
94     {
95         return false;
96     }
97 
setProgressListener(ProgressListener * pl)98     void        setProgressListener (ProgressListener* pl) override
99     {
100         plistener = pl;
101     }
102 
103     void        convertColorSpace(Imagefloat* image, const procparams::ColorManagementParams &cmp, const ColorTemp &wb) override;// RAWParams raw will not be used for non-raw files (see imagesource.h)
104     static void colorSpaceConversion (Imagefloat* im, const procparams::ColorManagementParams &cmp, cmsHPROFILE embedded, IIOSampleFormat sampleFormat);
105 
isRGBSourceModified()106     bool        isRGBSourceModified() const override
107     {
108         return rgbSourceModified;
109     }
setCurrentFrame(unsigned int frameNum)110     void setCurrentFrame(unsigned int frameNum) override {}
getFrameCount()111     int getFrameCount() override {return 1;}
getFlatFieldAutoClipValue()112     int getFlatFieldAutoClipValue() override {return 0;}
113 
114 
getRawValues(int x,int y,int rotate,int & R,int & G,int & B)115     void getRawValues(int x, int y, int rotate, int &R, int &G, int &B) override { R = G = B = 0;}
116 
117     void        flushRGB          () override;
captureSharpening(const procparams::CaptureSharpeningParams & sharpeningParams,bool showMask,double & conrastThreshold,double & radius)118     void captureSharpening(const procparams::CaptureSharpeningParams &sharpeningParams, bool showMask, double &conrastThreshold, double &radius) override {};
119 };
120 
121 }
122