CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

csgfx/quantize.h

Go to the documentation of this file.
00001 /*
00002     RGB to paletted image quantization routine
00003     Copyright (C) 2000 by Andrew Zabolotny <bit@eltech.ru>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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_CSGFX_EXPORT csColorQuantizer
00130 {
00131 private:
00132   friend struct csColorBox;
00133 
00134   // The storage for color usage histogram.
00135   uint16 *hist;
00136   // Total number of colors that were used to create the histogram.
00137   unsigned int hist_pixels;
00138 
00139   // The storage for color space boxes.
00140   csColorBox *box;
00141   // Number of valid color boxes.
00142   int boxcount;
00143   // The storage for color indices.
00144   uint8 *color_index;
00145 
00146   // The state of quantization variables
00147   enum
00148   {
00149     // Uninitialized: initial state
00150     qsNone,
00151     // Counting color frequencies
00152     qsCount,
00153     // Remapping input images to output
00154     qsRemap
00155   } qState;
00156 
00157   static int compare_boxes (const void *i1, const void *i2);
00158 
00159 public:
00161   csColorQuantizer ();
00163   ~csColorQuantizer ();
00164 
00187   void DoRGB (csRGBpixel *image, int pixels, int pixperline,
00188     uint8 *&outimage, csRGBpixel *&outpalette, int &maxcolors, bool dither);
00189 
00191   void Begin ();
00193   void End ();
00195   void Count (csRGBpixel *image, int pixels, csRGBpixel *transp = 0);
00197   void Bias (csRGBpixel *colors, int count, int weight);
00199   void Palette (csRGBpixel *&outpalette, int &maxcolors,
00200     csRGBpixel *transp = 0);
00202   void Remap (csRGBpixel *image, int pixels, uint8 *&outimage,
00203     csRGBpixel *transp = 0);
00205   void RemapDither (csRGBpixel *image, int pixels, int pixperline,
00206     csRGBpixel *palette, int colors, uint8 *&outimage,
00207     csRGBpixel *transp = 0);
00208 };
00209 
00212 #endif // __CS_QUANTIZE_H__

Generated for Crystal Space by doxygen 1.2.18