00001 #ifndef COLORMODEL_HEADER_
00002 #define COLORMODEL_HEADER_
00003
00004 #include "../headers.h"
00005 #include "../fileUtil.h"
00006
00008
00010 class MColorModel: public IColorTransformer {
00011
00012 DECLARE_TypeInfo( MColorModel, "Color models"
00013 , "Splits image into color planes using some <b>color model</b> (RGB or YCbCr)"
00014 , {
00015 label: "Color model",
00016 desc: "The color model that will be used to encode the images",
00017 type: settingCombo("RGB\nYCbCr",1)
00018 }
00019 , {
00020 label: "Quality multiplier for R/Y channel",
00021 desc: "The real encoding quality for Red/Y channel\n"
00022 "will be multiplied by this number",
00023 type: settingFloat(0,1,1)
00024 }
00025 , {
00026 label: "Quality multiplier for G/Cb channel",
00027 desc: "The real encoding quality for Green/Cb channel\n"
00028 "will be multiplied by this number",
00029 type: settingFloat(0,0.5,1)
00030 }
00031 , {
00032 label: "Quality multiplier for B/Cr channel",
00033 desc: "The real encoding quality for Blue/Cr channel\n"
00034 "will be multiplied by this number",
00035 type: settingFloat(0,0.5,1)
00036 }
00037 );
00038
00039 protected:
00041 enum Settings { ColorModel, QualityMul1, QualityMul2, QualityMul3 };
00042
00043 int numOfModels() { return 1+countEOLs( info().setType[ColorModel].type.data.text ); }
00044 float qualityMul(int channel) {
00045 ASSERT(channel>=0 && channel<3);
00046 return settings[QualityMul1+channel].val.f;
00047 }
00048
00049 protected:
00050 PlaneList ownedPlanes;
00051
00052 protected:
00053
00055 ~MColorModel() {
00056 for (PlaneList::iterator it=ownedPlanes.begin(); it!=ownedPlanes.end(); ++it) {
00057 it->pixels.free();
00058 delete it->settings;
00059 }
00060 }
00061
00062 public:
00065 PlaneList image2planes(const QImage &toEncode,const PlaneSettings &prototype);
00066 QImage planes2image();
00067
00068 void writeData(std::ostream &file)
00069 { put<Uchar>( file, settingsInt(ColorModel) ); }
00070 PlaneList readData(std::istream &file,const PlaneSettings &prototype);
00072 protected:
00075 PlaneList createPlanes(IRoot::Mode mode,const PlaneSettings &prototype);
00076 };
00077
00078 #endif