00001
00002
00003
00004
00005
00006 #ifndef H_CPPPDFColorSpace
00007 #define H_CPPPDFColorSpace
00008
00009 #include <C/PDF/TRN_ColorSpace.h>
00010 #include <Common/Common.h>
00011 #include <PDF/Function.h>
00012
00013 namespace pdftron {
00014 namespace PDF {
00015
00016
00021 class ColorPt
00022 {
00023 public:
00024
00028 explicit ColorPt(double x = 0, double y = 0, double z = 0, double w = 0);
00029 ColorPt(const ColorPt& co);
00030 ~ColorPt();
00031
00032 ColorPt& operator= (const ColorPt& co);
00033 bool operator== (const ColorPt& co) const;
00034
00042 void Set(double x = 0, double y = 0, double z = 0, double w = 0);
00043
00069 void Set(int colorant_index, double colorant_value);
00070
00084 double Get(int colorant_index) const;
00085
00093 void SetColorantNum(int num);
00094
00096 TRN_ColorPt m_c;
00098 };
00099
00100
00101
00102
00118 class ColorSpace
00119 {
00120 public:
00121
00122
00123
00127 static ColorSpace CreateDeviceGray();
00128
00132 static ColorSpace CreateDeviceRGB();
00133
00137 static ColorSpace CreateDeviceCMYK();
00138
00142 static ColorSpace CreatePattern();
00143
00147 static ColorSpace CreateICC(SDF::SDFDoc& doc, const UString& filepath);
00148 static ColorSpace CreateICC(SDF::SDFDoc& doc, Filters::Filter stm);
00149 static ColorSpace CreateICC(SDF::SDFDoc& doc, const UChar* buf, size_t buf_sz);
00150
00156 ColorSpace (SDF::Obj color_space = 0);
00157 ColorSpace(const ColorSpace& c);
00158 ColorSpace& operator=(const ColorSpace& c);
00159
00163 ~ColorSpace();
00164
00165 enum Type
00166 {
00167 e_device_gray,
00168 e_device_rgb,
00169 e_device_cmyk,
00170 e_cal_gray,
00171 e_cal_rgb,
00172 e_lab,
00173 e_icc,
00174 e_indexed,
00175 e_pattern,
00176 e_separation,
00177 e_device_n,
00178 e_null
00179 };
00180
00181
00182
00190 static int GetComponentNum(Type cs_type, SDF::Obj cs);
00191
00198 static Type GetType(SDF::Obj cs);
00199
00203 Type GetType() const;
00204
00208 SDF::Obj GetSDFObj ();
00209
00214 int GetComponentNum();
00215
00220 void InitColor(ColorPt& out_colorants);
00221
00234 void InitComponentRanges(std::vector<double>& out_decode_low, std::vector<double>& out_decode_range);
00235
00246 void Convert2Gray(const ColorPt& in_color, ColorPt& out_color);
00247
00258 void Convert2RGB(const ColorPt& in_color, ColorPt& out_color);
00259
00270 void Convert2CMYK(const ColorPt& in_color, ColorPt& out_color);
00271
00277 ColorSpace GetAlternateColorSpace();
00278
00283 ColorSpace GetBaseColorSpace();
00284
00285
00286
00294 int GetHighVal();
00295
00302 const UChar* GetLookupTable();
00303
00312 void GetBaseColor(UChar color_idx, ColorPt& out_color);
00313
00314
00315
00323 bool IsNone();
00324
00325
00326
00332 bool IsAll();
00333
00340 Function GetTintFunction();
00341
00342
00343
00345 ColorSpace(TRN_ColorSpace impl);
00346 TRN_ColorSpace mp_cs;
00348 };
00349
00350
00351 #include <Impl/ColorSpace.inl>
00352
00353 };
00354 };
00355
00356 #endif