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 //
20 // A class representing a 16 bit rgb image with separate planes and 16 byte aligned data
21 //
22 #pragma once
23 
24 #include "imageio.h"
25 
26 namespace rtengine
27 {
28 
29 class Image8;
30 class Imagefloat;
31 
32 class Image16 : public IImage16, public ImageIO
33 {
34 
35 public:
36 
37     Image16();
38     Image16(int width, int height);
39     ~Image16() override;
40 
41     Image16* copy() const;
42 
43     Image8* to8() const;
44 
45     void getStdImage(const ColorTemp &ctemp, int tran, Imagefloat* image, PreviewProps pp) const override;
46 
getType()47     const char* getType() const override
48     {
49         return sImage16;
50     }
getBPS()51     int getBPS() const override
52     {
53         return 8 * sizeof(unsigned short);
54     }
55 
56     void getScanline(int row, unsigned char* buffer, int bps, bool isFloat = false) const override;
57     void setScanline(int row, const unsigned char* buffer, int bps, unsigned int numSamples) override;
58 
59     // functions inherited from IImage16:
getMutex()60     MyMutex& getMutex() override
61     {
62         return mutex();
63     }
64 
getProfile()65     cmsHPROFILE getProfile() const override
66     {
67         return getEmbeddedProfile();
68     }
69 
getBitsPerPixel()70     int getBitsPerPixel() const override
71     {
72         return 8 * sizeof(unsigned short);
73     }
74 
saveToFile(const Glib::ustring & fname)75     int saveToFile(const Glib::ustring &fname) const override
76     {
77         return save(fname);
78     }
79 
80     int saveAsPNG(const Glib::ustring &fname, int bps = -1) const override
81     {
82         return savePNG(fname, bps);
83     }
84 
85     int saveAsJPEG(const Glib::ustring &fname, int quality = 100, int subSamp = 3) const override
86     {
87         return saveJPEG(fname, quality, subSamp);
88     }
89 
90     int saveAsTIFF(const Glib::ustring &fname, int bps = -1, bool isFloat = false, bool uncompressed = false) const override
91     {
92         return saveTIFF(fname, bps, isFloat, uncompressed);
93     }
94 
setSaveProgressListener(ProgressListener * pl)95     void setSaveProgressListener(ProgressListener* pl) override
96     {
97         setProgressListener(pl);
98     }
99 
free()100     void free() override
101     {
102         delete this;
103     }
104     void ExecCMSTransform(cmsHTRANSFORM hTransform);
105 
106     /* void                 ExecCMSTransform(cmsHTRANSFORM hTransform, const LabImage &labImage, int cx, int cy); */
107 };
108 
109 }
110