<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Crystal Space 1.2.1: csgfx/quantize.h Source File (Crystal Space 1.2.1 Public API Reference)</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <table border="0" cellpadding="0" cellspacing="0" width="100%" class="head"> <tr height="59"> <td class="head" width="202" valign="bottom" style="padding-left:0;"><a href="http://www.crystalspace3d.org/"><img src="csblur.png" width="236" height="59" alt="CrystalSpace" border="0"></a></td> <td class="head"><h2>Public API Reference</h2></td> </tr> <tr height="11"> <td colspan="2" class="headshadow" valign="top" style="padding-left:0;"><img src="csblurb.png" width="236" height="11" alt="" border="0"></td> </tr> </table> <div class="content"> <!-- Generated by Doxygen 1.5.3 --> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="classes.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> </ul> </div> <h1>csgfx/quantize.h</h1><a href="quantize_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> RGB to paletted image quantization routine</span> <a name="l00003"></a>00003 <span class="comment"> Copyright (C) 2000 by Andrew Zabolotny <bit@eltech.ru></span> <a name="l00004"></a>00004 <span class="comment"></span> <a name="l00005"></a>00005 <span class="comment"> This library is free software; you can redistribute it and/or</span> <a name="l00006"></a>00006 <span class="comment"> modify it under the terms of the GNU Library General Public</span> <a name="l00007"></a>00007 <span class="comment"> License as published by the Free Software Foundation; either</span> <a name="l00008"></a>00008 <span class="comment"> version 2 of the License, or (at your option) any later version.</span> <a name="l00009"></a>00009 <span class="comment"></span> <a name="l00010"></a>00010 <span class="comment"> This library is distributed in the hope that it will be useful,</span> <a name="l00011"></a>00011 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00012"></a>00012 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00013"></a>00013 <span class="comment"> Library General Public License for more details.</span> <a name="l00014"></a>00014 <span class="comment"></span> <a name="l00015"></a>00015 <span class="comment"> You should have received a copy of the GNU Library General Public</span> <a name="l00016"></a>00016 <span class="comment"> License along with this library; if not, write to the Free</span> <a name="l00017"></a>00017 <span class="comment"> Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</span> <a name="l00018"></a>00018 <span class="comment">*/</span> <a name="l00019"></a>00019 <a name="l00020"></a>00020 <span class="preprocessor">#ifndef __CS_QUANTIZE_H__</span> <a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define __CS_QUANTIZE_H__</span> <a name="l00022"></a>00022 <span class="preprocessor"></span> <a name="l00031"></a>00031 <span class="preprocessor">#include "csextern.h"</span> <a name="l00032"></a>00032 <a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="rgbpixel_8h.html" title="RGB colors.">csgfx/rgbpixel.h</a>"</span> <a name="l00034"></a>00034 <a name="l00035"></a>00035 <span class="keyword">struct </span>csColorBox; <a name="l00036"></a>00036 <a name="l00129"></a><a class="code" href="classcsColorQuantizer.html">00129</a> <span class="keyword">class </span>CS_CRYSTALSPACE_EXPORT <a class="code" href="classcsColorQuantizer.html" title="Color quantizer.">csColorQuantizer</a> <a name="l00130"></a>00130 { <a name="l00131"></a>00131 <span class="keyword">private</span>: <a name="l00132"></a><a class="code" href="classcsColorQuantizer.html#91ce807a34273beb4a3f93fae8416ece">00132</a> <span class="keyword">friend</span> <span class="keyword">struct </span>csColorBox; <a name="l00133"></a>00133 <span class="keyword">struct </span>ColorIndex <a name="l00134"></a>00134 { <a name="l00135"></a>00135 <span class="keywordtype">int</span> index; <a name="l00136"></a>00136 csColorBox* box; <a name="l00137"></a>00137 <a name="l00138"></a>00138 ColorIndex() : box(0) {} <a name="l00139"></a>00139 }; <a name="l00140"></a>00140 <a name="l00141"></a>00141 <span class="comment">// The storage for color usage histogram.</span> <a name="l00142"></a>00142 <a class="code" href="group__util.html#g05f6b0ae8f6a6e135b0e290c25fe0e4e" title="unsigned 16-bit integer (0..65 535)">uint16</a> *hist; <a name="l00143"></a>00143 <span class="comment">// Total number of colors that were used to create the histogram.</span> <a name="l00144"></a>00144 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> hist_pixels; <a name="l00145"></a>00145 <a name="l00146"></a>00146 <span class="comment">// The storage for color space boxes.</span> <a name="l00147"></a>00147 csColorBox *box; <a name="l00148"></a>00148 <span class="comment">// Number of valid color boxes.</span> <a name="l00149"></a>00149 <span class="keywordtype">int</span> boxcount; <a name="l00150"></a>00150 <span class="comment">// The storage for color indices.</span> <a name="l00151"></a>00151 ColorIndex* color_index; <a name="l00152"></a>00152 <a name="l00153"></a>00153 <span class="comment">// The state of quantization variables</span> <a name="l00154"></a>00154 <span class="keyword">enum</span> <a name="l00155"></a>00155 { <a name="l00156"></a>00156 <span class="comment">// Uninitialized: initial state</span> <a name="l00157"></a>00157 qsNone, <a name="l00158"></a>00158 <span class="comment">// Counting color frequencies</span> <a name="l00159"></a>00159 qsCount, <a name="l00160"></a>00160 <span class="comment">// Remapping input images to output</span> <a name="l00161"></a>00161 qsRemap <a name="l00162"></a>00162 } qState; <a name="l00163"></a>00163 <a name="l00164"></a>00164 <span class="keyword">static</span> <span class="keywordtype">int</span> compare_boxes (<span class="keyword">const</span> <span class="keywordtype">void</span> *i1, <span class="keyword">const</span> <span class="keywordtype">void</span> *i2); <a name="l00165"></a>00165 <a name="l00166"></a>00166 <span class="keyword">public</span>: <a name="l00168"></a>00168 <a class="code" href="classcsColorQuantizer.html" title="Color quantizer.">csColorQuantizer</a> (); <a name="l00170"></a>00170 ~<a class="code" href="classcsColorQuantizer.html" title="Color quantizer.">csColorQuantizer</a> (); <a name="l00171"></a>00171 <a name="l00194"></a>00194 <span class="keywordtype">void</span> DoRGB (<a class="code" href="structcsRGBpixel.html" title="An RGB pixel.">csRGBpixel</a> *image, <span class="keywordtype">int</span> pixels, <span class="keywordtype">int</span> pixperline, <a name="l00195"></a>00195 <a class="code" href="group__util.html#gdde6aaee8457bee49c2a92621fe22b79" title="unsigned 8-bit integer (0..255)">uint8</a> *&outimage, <a class="code" href="structcsRGBpixel.html" title="An RGB pixel.">csRGBpixel</a> *&outpalette, <span class="keywordtype">int</span> &maxcolors, <span class="keywordtype">bool</span> dither); <a name="l00196"></a>00196 <a name="l00198"></a>00198 <span class="keywordtype">void</span> Begin (); <a name="l00200"></a>00200 <span class="keywordtype">void</span> End (); <a name="l00202"></a>00202 <span class="keywordtype">void</span> Count (<a class="code" href="structcsRGBpixel.html" title="An RGB pixel.">csRGBpixel</a> *image, <span class="keywordtype">int</span> pixels, <a class="code" href="structcsRGBpixel.html" title="An RGB pixel.">csRGBpixel</a> *transp = 0); <a name="l00204"></a>00204 <span class="keywordtype">void</span> Bias (<a class="code" href="structcsRGBpixel.html" title="An RGB pixel.">csRGBpixel</a> *colors, <span class="keywordtype">int</span> count, <span class="keywordtype">int</span> weight); <a name="l00206"></a>00206 <span class="keywordtype">void</span> Palette (<a class="code" href="structcsRGBpixel.html" title="An RGB pixel.">csRGBpixel</a> *&outpalette, <span class="keywordtype">int</span> &maxcolors, <a name="l00207"></a>00207 <a class="code" href="structcsRGBpixel.html" title="An RGB pixel.">csRGBpixel</a> *transp = 0); <a name="l00209"></a>00209 <span class="keywordtype">void</span> Remap (<a class="code" href="structcsRGBpixel.html" title="An RGB pixel.">csRGBpixel</a> *image, <span class="keywordtype">int</span> pixels, <a class="code" href="group__util.html#gdde6aaee8457bee49c2a92621fe22b79" title="unsigned 8-bit integer (0..255)">uint8</a> *&outimage, <a name="l00210"></a>00210 <a class="code" href="structcsRGBpixel.html" title="An RGB pixel.">csRGBpixel</a> *transp = 0); <a name="l00212"></a>00212 <span class="keywordtype">void</span> RemapDither (<a class="code" href="structcsRGBpixel.html" title="An RGB pixel.">csRGBpixel</a> *image, <span class="keywordtype">int</span> pixels, <span class="keywordtype">int</span> pixperline, <a name="l00213"></a>00213 <a class="code" href="structcsRGBpixel.html" title="An RGB pixel.">csRGBpixel</a> *palette, <span class="keywordtype">int</span> colors, <a class="code" href="group__util.html#gdde6aaee8457bee49c2a92621fe22b79" title="unsigned 8-bit integer (0..255)">uint8</a> *&outimage, <a name="l00214"></a>00214 <a class="code" href="structcsRGBpixel.html" title="An RGB pixel.">csRGBpixel</a> *transp = 0); <a name="l00215"></a>00215 }; <a name="l00216"></a>00216 <a name="l00219"></a>00219 <span class="preprocessor">#endif // __CS_QUANTIZE_H__</span> </pre></div><hr size="1"><address><small>Generated for Crystal Space 1.2.1 by <a href="http://www.doxygen.org/index.html">doxygen</a> 1.5.3 </small></address> </div></body> </html>