1 #ifndef COLORMODEL_HEADER_
2 #define COLORMODEL_HEADER_
4 #include "../headers.h"
5 #include "../fileUtil.h"
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)"
16 desc
: "The color model that will be used to encode the images",
17 type
: settingCombo("RGB\nYCbCr",1)
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)
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)
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)
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
;
50 PlaneList ownedPlanes
; ///< the list of color planes, owned by the module
53 // Construction and destruction
54 /** Just frees ::ownedPlanes */
56 for (PlaneList::iterator it
=ownedPlanes
.begin(); it
!=ownedPlanes
.end(); ++it
) {
63 /** \name IColorTransformer interface
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
);
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
);