LightWrap++
AC++wrapperfortheLightWave3DSDK
colour_management.h
Go to the documentation of this file.
1 
8 #ifndef LWPP_COLORSPACE_H
9 #define LWPP_COLORSPACE_H
10 
11 #include <lwpp/storeable.h>
12 #include <lwpp/wrapper.h>
13 
14 namespace lwpp
15 {
16 
17 #define LWPP_COLORSPACEFUNCS_GLOBAL "LWColorSpace"
18 
26  };
27 
39  };
40 
45  };
46 
48  lwcsl_RGB = 0,
51  };
52 
53  struct st_lwimagelookup;
61  typedef void LWPixelConversionRGBFunc( struct st_lwimagelookup *, float *, float * );
62  typedef void LWPixelConversionAlphaFunc( struct st_lwimagelookup *, float *, float * );
71  typedef struct st_lwcolorspacefuncs {
72 
73  /* These function are used to get the color space of a loaded converter or load one from the disk. */
74 
78  /* These functions are used to get the pixel conversion functions. */
79 
80  LWPixelConversionRGBFunc *(*getPixelConversionRGB )( LWColourSpace, LWColourSpaceConversion, struct st_lwimagelookup ** );
81  LWPixelConversionAlphaFunc *(*getPixelConversionAlpha)( LWColourSpace, LWColourSpaceConversion, struct st_lwimagelookup ** );
82 
83  /* These functions are used to get color space names and file names, based on type. */
84 
85  const char *(*colorSpaceName )( LWColorSpaceType );
86  const char *(*colorSpaceFile )( LWColorSpaceType );
88  /* These functions are used in pop-ups. */
89 
91  const char *(*nameOfColorSpaces )( LWColourSpaceLayer, int);
94 
95  /* This functions is to change the currently selected color space. */
96 
98 
100 
101 
102 
103  class ColourManager : public PopUpCallback, public Storeable, public GlobalBase<LWColorSpaceFuncs>
104  {
105  LWPixelConversionRGBFunc *toLinear, *toColourSpace;
106  st_lwimagelookup *ilt, *ilf;
107  char *fileLUT;
108  LWColorSpaceType type;
109  LWColourSpace cSpace;
110  LWColourSpaceLayer mLayer;
111  bool useDefault;
112  bool Standalone;
113  bool supportLUT;
114  protected:
116 
119  virtual size_t popCount();
121 
125  virtual const char *popName(int n);
126  public:
128  ColourManager(LWColorSpaceType _type, LWColourSpaceLayer layer = lwcsl_RGB, bool _supportLUT = false);
129 
132 
134  ColourManager(ColourManager const& f);
135 
137 
138  bool operator!=(const ColourManager &comp) const;
139 
140  void Update();
141 
142  void convertToLinear(float *from, float *to)
143  {
144  if (toLinear)
145  {
146  toLinear(ilt, from, to);
147  }
148  }
149  void convertToColourSpace(float *from, float *to)
150  {
151  if (toColourSpace)
152  {
153  toColourSpace(ilf, from, to);
154  }
155  }
156 
157  void convertToLinear(float *from)
158  {
159  if (toLinear)
160  {
161  toLinear(ilt, from, from);
162  }
163  }
164  void convertToColourSpace(float *from)
165  {
166  if (toColourSpace)
167  {
168  toColourSpace(ilf, from, from);
169  }
170  }
171 
172  float convertToLinear(float from)
173  {
174  if (toLinear)
175  {
176  float rgb[]= {from, 0.0, 0.0};
177  toLinear(ilt, rgb, rgb);
178  return rgb[0];
179  }
180  return from;
181  }
182  float convertToColourSpace(float from)
183  {
184  if (toColourSpace)
185  {
186  float rgb[]= {from, 0.0, 0.0};
187  toColourSpace(ilf, rgb, rgb);
188  return rgb[0];
189  }
190  return from;
191  }
192 
193  int getIndex();
194 
195  void setIndex(int idx);
196 
197  virtual LWError Load(const LoadState &ls );
198 
199  virtual LWError Save(const SaveState &ss );
200 
201  LWColourSpace getColourSpace() const {return cSpace;}
202 
203  };
204 
205 }
206 #endif // LWPP_COLORPSPACE_H