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
00034 #include "csgfx/rgbpixel.h"
00035
00036 struct csColorBox;
00037
00130 class csColorQuantizer
00131 {
00132 private:
00133 friend struct csColorBox;
00134
00135
00136 uint16 *hist;
00137
00138 unsigned int hist_pixels;
00139
00140
00141 csColorBox *box;
00142
00143 int boxcount;
00144
00145 uint8 *color_index;
00146
00147
00148 enum
00149 {
00150
00151 qsNone,
00152
00153 qsCount,
00154
00155 qsRemap
00156 } qState;
00157
00158 static int compare_boxes (const void *i1, const void *i2);
00159
00160 public:
00162 csColorQuantizer ();
00164 ~csColorQuantizer ();
00165
00188 void DoRGB (csRGBpixel *image, int pixels, int pixperline,
00189 uint8 *&outimage, csRGBpixel *&outpalette, int &maxcolors, bool dither);
00190
00192 void Begin ();
00194 void End ();
00196 void Count (csRGBpixel *image, int pixels, csRGBpixel *transp = NULL);
00198 void Bias (csRGBpixel *colors, int count, int weight);
00200 void Palette (csRGBpixel *&outpalette, int &maxcolors,
00201 csRGBpixel *transp = NULL);
00203 void Remap (csRGBpixel *image, int pixels, uint8 *&outimage,
00204 csRGBpixel *transp = NULL);
00206 void RemapDither (csRGBpixel *image, int pixels, int pixperline,
00207 csRGBpixel *palette, int colors, uint8 *&outimage,
00208 csRGBpixel *transp = NULL);
00209 };
00210
00213 #endif // __CS_QUANTIZE_H__