Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CS_QUANTIZE_H__
00021 #define __CS_QUANTIZE_H__
00022
00031 #include "csextern.h"
00032
00033 #include "csgfx/rgbpixel.h"
00034
00035 struct csColorBox;
00036
00129 class CS_CRYSTALSPACE_EXPORT csColorQuantizer
00130 {
00131 private:
00132 friend struct csColorBox;
00133 struct ColorIndex
00134 {
00135 int index;
00136 csColorBox* box;
00137
00138 ColorIndex () : box(0) {}
00139 };
00140
00141
00142 uint16* hist;
00143
00144 unsigned int hist_pixels;
00145
00146
00147 csColorBox* box;
00148
00149 int boxcount;
00150
00151 ColorIndex* color_index;
00152
00153
00154 enum
00155 {
00156
00157 qsNone,
00158
00159 qsCount,
00160
00161 qsRemap
00162 } qState;
00163
00164 static int compare_boxes (const void* i1, const void* i2);
00165
00166 public:
00168 csColorQuantizer ();
00170 ~csColorQuantizer ();
00171
00194 void DoRGB (csRGBpixel* image, int pixels, int pixperline,
00195 uint8*& outimage, csRGBpixel*& outpalette, int& maxcolors, bool dither);
00196
00198 void Begin ();
00200 void End ();
00202 void Count (csRGBpixel* image, int pixels, csRGBpixel* transp = 0);
00204 void Bias (csRGBpixel* colors, int count, int weight);
00206 void Palette (csRGBpixel*& outpalette, int &maxcolors,
00207 csRGBpixel* transp = 0);
00209 void Remap (csRGBpixel* image, int pixels, uint8*& outimage,
00210 csRGBpixel* transp = 0);
00212 void RemapDither (csRGBpixel* image, int pixels, int pixperline,
00213 csRGBpixel* palette, int colors, uint8*& outimage,
00214 csRGBpixel* transp = 0);
00215 };
00216
00219 #endif // __CS_QUANTIZE_H__