ColorSpace.h

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------------------
00002 // Copyright (c) 2001-2008 by PDFTron Systems Inc. All Rights Reserved.
00003 // Consult legal.txt regarding legal and license information.
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         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);
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         // Common ColorSpace methods ----------------------------------------------------
00123 
00127          static ColorSpace CreateDeviceGray();
00128 
00132          static ColorSpace CreateDeviceRGB();
00133 
00137          static ColorSpace CreateDeviceCMYK();
00138 
00142          static ColorSpace CreatePattern();
00143 
00149          ColorSpace (SDF::Obj color_space = 0);
00150          ColorSpace(const ColorSpace& c);
00151          ColorSpace& operator=(const ColorSpace& c);
00152 
00156          ~ColorSpace();
00157         
00158         enum Type
00159         {
00160                 e_device_gray,
00161                 e_device_rgb,
00162                 e_device_cmyk,
00163                 e_cal_gray,
00164                 e_cal_rgb,
00165                 e_lab,
00166                 e_icc,
00167                 e_indexed,
00168                 e_pattern,
00169                 e_separation,
00170                 e_device_n,
00171                 e_null
00172         };
00173 
00174         // Common Static/Global methods ----------------------------------------------------
00175 
00183          static int GetComponentNum(Type cs_type, SDF::Obj cs);
00184 
00191          static Type GetType(SDF::Obj cs);
00192 
00196          Type GetType() const;
00197 
00201          SDF::Obj GetSDFObj ();
00202 
00207          int GetComponentNum();
00208 
00213          void InitColor(ColorPt& out_colorants);
00214 
00227          void InitComponentRanges(std::vector<double>& out_decode_low, std::vector<double>& out_decode_range);
00228 
00239          void Convert2Gray(const ColorPt& in_color, ColorPt& out_color);
00240 
00251          void Convert2RGB(const ColorPt& in_color, ColorPt& out_color);
00252 
00263          void Convert2CMYK(const ColorPt& in_color, ColorPt& out_color);
00264 
00270          ColorSpace GetAlternateColorSpace();
00271 
00276          ColorSpace GetBaseColorSpace();
00277 
00278         // Indexed color space methods --------------------------------------------------
00279 
00287          int GetHighVal();
00288 
00295          const UChar* GetLookupTable();
00296 
00305          void GetBaseColor(UChar color_idx, ColorPt& out_color);
00306 
00307         // Separation color space methods -----------------------------------------------
00308 
00315          Function GetTintFunction();
00316 
00322          bool IsAll();
00323 
00330          bool IsNone();
00331 
00333         ColorSpace(TRN_ColorSpace impl);
00334         TRN_ColorSpace mp_cs;
00336 };
00337 
00338 
00339 #include <Impl/ColorSpace.inl>
00340 
00341         };      // namespace PDF
00342 };      // namespace pdftron
00343 
00344 #endif

© 2002-2008 PDFTron Systems Inc.