Fixed wrong prediction for incomplete ranges.
[fic.git] / modules / colorModel.h
blob9c320eb1df88ebab7a85b7c702b74e2d17bb40ce
1 #ifndef COLORMODEL_HEADER_
2 #define COLORMODEL_HEADER_
4 #include "../headers.h"
5 #include "../fileUtil.h"
7 /// \ingroup modules
8 /** Simple color transformer for affine models. It currently supports RGB and YCbCr
9 * color models and allows to se quality multipliers for individual color channels. */
10 class MColorModel: public IColorTransformer {
12 DECLARE_TypeInfo( MColorModel, "Color models"
13 , "Splits image into color planes using some <b>color model</b> (RGB or YCbCr)"
14 , {
15 label: "Color model",
16 desc: "The color model that will be used to encode the images",
17 type: settingCombo("RGB\nYCbCr",1)
19 , {
20 label: "Quality multiplier for R/Y channel",
21 desc: "The real encoding quality for Red/Y channel\n"
22 "will be multiplied by this number",
23 type: settingFloat(0,1,1)
25 , {
26 label: "Quality multiplier for G/Cb channel",
27 desc: "The real encoding quality for Green/Cb channel\n"
28 "will be multiplied by this number",
29 type: settingFloat(0,0.5,1)
31 , {
32 label: "Quality multiplier for B/Cr channel",
33 desc: "The real encoding quality for Blue/Cr channel\n"
34 "will be multiplied by this number",
35 type: settingFloat(0,0.5,1)
39 protected:
40 /** Indices for settings */
41 enum Settings { ColorModel, QualityMul1, QualityMul2, QualityMul3 };
42 // Settings-retrieval methods
43 int numOfModels() { return 1+countEOLs( info().setType[ColorModel].type.data.text ); }
44 float qualityMul(int channel) {
45 ASSERT(channel>=0 && channel<3);
46 return settings[QualityMul1+channel].val.f;
49 protected:
50 PlaneList ownedPlanes; ///< the list of color planes, owned by the module
52 protected:
53 // Construction and destruction
54 /** Just frees ::ownedPlanes */
55 ~MColorModel() {
56 for (PlaneList::iterator it=ownedPlanes.begin(); it!=ownedPlanes.end(); ++it) {
57 it->pixels.free();
58 delete it->settings;
62 public:
63 /** \name IColorTransformer interface
64 * @{ */
65 PlaneList image2planes(const QImage &toEncode,const PlaneSettings &prototype);
66 QImage planes2image();
68 void writeData(std::ostream &file)
69 { put<Uchar>( file, settingsInt(ColorModel) ); }
70 PlaneList readData(std::istream &file,const PlaneSettings &prototype);
71 /// @}
72 protected:
73 /** Creates a list of planes according to \p prototype,
74 * makes new matrices and adjusts encoding parameters */
75 PlaneList createPlanes(IRoot::Mode mode,const PlaneSettings &prototype);
78 #endif