File: plfilterquantize_8h-source.html

package info (click to toggle)
paintlib 2.6.2-8
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 7,900 kB
  • ctags: 3,875
  • sloc: cpp: 25,209; sh: 10,600; ansic: 1,891; makefile: 119
file content (176 lines) | stat: -rw-r--r-- 14,565 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<!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>paintlib: plfilterquantize.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.2 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Compound&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Compound&nbsp;Members</a></div>
<h1>plfilterquantize.h</h1><div class="fragment"><pre>00001 <span class="comment">/*</span>
00002 <span class="comment">/--------------------------------------------------------------------</span>
00003 <span class="comment">|</span>
00004 <span class="comment">|      $Id: plfilterquantize_8h-source.html,v 1.4 2004/09/15 15:26:29 uzadow Exp $</span>
00005 <span class="comment">|</span>
00006 <span class="comment">|      Copyright (c) 1996-2002 Ulrich von Zadow</span>
00007 <span class="comment">|</span>
00008 <span class="comment">\--------------------------------------------------------------------</span>
00009 <span class="comment">*/</span>
00010 
00011 <span class="preprocessor">#if !defined(INCL_PLFILTERQUANTIZE)</span>
00012 <span class="preprocessor"></span><span class="preprocessor">#define INCL_PLFILTERQUANTIZE</span>
00013 <span class="preprocessor"></span>
00014 <span class="preprocessor">#if _MSC_VER &gt;= 1000</span>
00015 <span class="preprocessor"></span><span class="preprocessor">#pragma once</span>
00016 <span class="preprocessor"></span><span class="preprocessor">#endif // _MSC_VER &gt;= 1000</span>
00017 <span class="preprocessor"></span>
00018 <span class="preprocessor">#include "plfilter.h"</span>
00019 <span class="preprocessor">#include "plbitmap.h"</span>
00020 
00021 <span class="preprocessor">#define PLDTHPAL_MEDIAN          0       // Median Cut</span>
00022 <span class="preprocessor"></span><span class="preprocessor">#define PLDTHPAL_POPULARITY      1       // Popularity Sort</span>
00023 <span class="preprocessor"></span><span class="preprocessor">#define PLDTHPAL_DEFAULT         2       // Use Default Palette</span>
00024 <span class="preprocessor"></span><span class="preprocessor">#define PLDTHPAL_USERDEFINED     3       // Use Palette set by SetUserPalette()</span>
00025 <span class="preprocessor"></span>
00026 <span class="preprocessor">#define PLDTH_NONE      0       // None</span>
00027 <span class="preprocessor"></span><span class="preprocessor">#define PLDTH_ORDERED   1       // Ordered Dithering</span>
00028 <span class="preprocessor"></span><span class="preprocessor">#define PLDTH_FS        2       // Floyd-Steinberg Dithering</span>
00029 <span class="preprocessor"></span><span class="comment">//#define PLDTH_JITTER    3       // Jitter preprocessing</span>
00030 
00031 <span class="comment"></span>
00032 <span class="comment">//! Returns an 8 bpp bitmap containing a best-fit representation of the</span>
00033 <span class="comment">//! source 32 bpp bitmap.</span>
<a name="l00034"></a><a class="code" href="classPLFilterQuantize.html">00034</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="classPLFilterQuantize.html">PLFilterQuantize</a> : <span class="keyword">public</span> <a class="code" href="classPLFilter.html">PLFilter</a>
00035 {
00036 <span class="keyword">public</span>:<span class="comment"></span>
00037 <span class="comment">  //! DitherPaletteType and DitherType determine the type of quantization:</span>
00038 <span class="comment">  //!</span>
00039 <span class="comment">  //! PLDTHPAL_MEDIAN (0): Median cut</span>
00040 <span class="comment">  //!</span>
00041 <span class="comment">  //! PLDTHPAL_POPULARITY (1): Popularity sort</span>
00042 <span class="comment">  //!</span>
00043 <span class="comment">  //! PLDTHPAL_DEFAULT (2): Use default palette</span>
00044 <span class="comment">  //!</span>
00045 <span class="comment">  //! PLDTHPAL_USERDEFINED (3): Use palette defined by SetUserPalette();</span>
00046 <span class="comment">  //!</span>
00047 <span class="comment">  //!</span>
00048 <span class="comment">  //! PLDTH_NONE (0): No dithering</span>
00049 <span class="comment">  //!</span>
00050 <span class="comment">  //! PLDTH_ORDERED (1): Ordered dithering</span>
00051 <span class="comment">  //!</span>
00052 <span class="comment">  //! PLDTH_FS (2): Floyd-Steinberg dithering</span>
00053 <span class="comment"></span>  <a class="code" href="classPLFilterQuantize.html#a0">PLFilterQuantize</a> (<span class="keywordtype">int</span> DitherPaletteType, <span class="keywordtype">int</span> DitherType);<span class="comment"></span>
00054 <span class="comment">  //!</span>
00055 <span class="comment"></span>  <span class="keyword">virtual</span> ~<a class="code" href="classPLFilterQuantize.html">PLFilterQuantize</a>();
00056 <span class="comment"></span>
00057 <span class="comment">  //!</span>
00058 <span class="comment"></span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classPLFilterQuantize.html#a2">Apply</a>(<a class="code" href="classPLBmpBase.html">PLBmpBase</a> * pBmpSource, <a class="code" href="classPLBmp.html">PLBmp</a> * pBmpDest) <span class="keyword">const</span>;
00059 <span class="comment"></span>
00060 <span class="comment">  //! For PLDTHPAL_USERDEFINED, sets the palette to use.</span>
00061 <span class="comment"></span>  <span class="keywordtype">void</span> <a class="code" href="classPLFilterQuantize.html#a3">SetUserPalette</a>(<span class="keyword">const</span> <a class="code" href="classPLPixel32.html">PLPixel32</a>* pPal);
00062 
00063   <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classPLPixel32.html">PLPixel32</a>* GetDefaultPalette ();
00064 
00065 <span class="keyword">private</span>:
00066   <span class="comment">// Local structs defining the quantization buffer</span>
00067   <span class="keyword">typedef</span> <span class="keyword">struct </span>tagQUBOX
00068   {
00069     <a class="code" href="classPLPixel32.html">PLPixel32</a> Corner0, Corner1;
00070     <a class="code" href="classPLPixel32.html">PLPixel32</a> Average;
00071     PLULONG count;
00072   } QUBOX;
00073 
00074   <span class="keyword">typedef</span> <span class="keyword">struct </span>tagHISTONODE
00075   {
00076     <span class="keywordtype">int</span>   index;
00077     PLULONG count;
00078   } HISTONODE;
00079 
00080   <span class="comment">// Private members</span>
00081   <span class="keywordtype">void</span> initLUT();
00082   <span class="keywordtype">void</span> deleteLUT();
00083 
00084   <span class="keywordtype">void</span> genMedianPalette (<a class="code" href="classPLBmpBase.html">PLBmpBase</a> * pBmpSource, <a class="code" href="classPLBmp.html">PLBmp</a> * pBmpDest) <span class="keyword">const</span>;
00085   <span class="keywordtype">void</span> split (QUBOX * pBox0, QUBOX * pBox1, <span class="keywordtype">int</span> ColComp) <span class="keyword">const</span>;
00086   <span class="keywordtype">void</span> squeeze(QUBOX * pBox) <span class="keyword">const</span>;
00087   <span class="keywordtype">void</span> genPopularityPalette (<a class="code" href="classPLBmpBase.html">PLBmpBase</a> * pBmpSource, <a class="code" href="classPLBmp.html">PLBmp</a> * pBmpDest) <span class="keyword">const</span>;
00088   <span class="keywordtype">void</span> genColorArray(<a class="code" href="classPLBmpBase.html">PLBmpBase</a> * pBmpSource) <span class="keyword">const</span>;
00089   <span class="keywordtype">void</span> genDefaultPalette (<a class="code" href="classPLBmpBase.html">PLBmpBase</a> * pBmpSource) <span class="keyword">const</span>;
00090   <span class="keywordtype">void</span> addColor(<a class="code" href="classPLPixel32.html">PLPixel32</a> col, PLULONG count) <span class="keyword">const</span>;
00091   <span class="keywordtype">void</span> makeBox(<a class="code" href="classPLPixel32.html">PLPixel32</a> col, <span class="keywordtype">int</span> i, PLULONG c) <span class="keyword">const</span>;
00092   <span class="keywordtype">int</span> getColorTableIndex (<a class="code" href="classPLPixel32.html">PLPixel32</a> col) <span class="keyword">const</span>;
00093   <span class="keywordtype">int</span> getShiftedColorTableIndex (<a class="code" href="classPLPixel32.html">PLPixel32</a> col) <span class="keyword">const</span>;
00094 
00095   <span class="keywordtype">void</span> ditherDestBmp(<a class="code" href="classPLBmpBase.html">PLBmpBase</a> * pBmpSource, <a class="code" href="classPLBmp.html">PLBmp</a> * pBmpDest) <span class="keyword">const</span>;
00096   <span class="keywordtype">void</span> jitterPixel (<span class="keywordtype">int</span> i, <span class="keywordtype">int</span> y, <a class="code" href="classPLPixel32.html">PLPixel32</a> * pPixel) <span class="keyword">const</span>;
00097   <span class="keywordtype">void</span> ditherPixelOrdered (<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <a class="code" href="classPLPixel32.html">PLPixel32</a> * pPixel) <span class="keyword">const</span>;
00098   <span class="keywordtype">void</span> ditherCompOrdered (<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, PLBYTE * pComp) <span class="keyword">const</span>;
00099   <span class="keywordtype">void</span> ditherPixelFS(<span class="keywordtype">double</span> * pR, <span class="keywordtype">double</span> * pG, <span class="keywordtype">double</span> * pB, <span class="keywordtype">double</span> * pCurErrors) <span class="keyword">const</span>;
00100   <span class="keywordtype">void</span> ditherCompFS (<span class="keywordtype">double</span> * pComp, <span class="keywordtype">double</span> Error) <span class="keyword">const</span>;
00101   PLBYTE getNeighbor (<a class="code" href="classPLPixel32.html">PLPixel32</a> Color, <a class="code" href="classPLPixel32.html">PLPixel32</a> * pPal) <span class="keyword">const</span>;
00102   <span class="keywordtype">int</span> colorDist (<a class="code" href="classPLPixel32.html">PLPixel32</a> c0, <a class="code" href="classPLPixel32.html">PLPixel32</a> c1) <span class="keyword">const</span>;
00103 
00104   <span class="keywordtype">int</span> clip (<span class="keywordtype">int</span> c) <span class="keyword">const</span>;
00105 
00106   <span class="keywordtype">int</span> m_DitherPaletteType;
00107   <span class="keywordtype">int</span> m_DitherType;
00108   <a class="code" href="classPLPixel32.html">PLPixel32</a>* m_pUserPal;
00109 
00110   HISTONODE ** m_ppHisto; <span class="comment">// Array of 32x32x32 color bins. Allocated</span>
00111                           <span class="comment">// sparsely to save memory.</span>
00112   QUBOX * m_pQuBoxes;     <span class="comment">// Array of 256 boxes, one for each color.</span>
00113 };
00114 
00115 <span class="keyword">inline</span> <span class="keywordtype">int</span> PLFilterQuantize::clip (<span class="keywordtype">int</span> c)<span class="keyword"> const</span>
00116 <span class="keyword"></span>{
00117   <span class="keywordflow">if</span> (c &gt; 255)
00118     <span class="keywordflow">return</span> 255;
00119   <span class="keywordflow">if</span> (c &lt; 0)
00120     <span class="keywordflow">return</span> 0;
00121   <span class="keywordflow">return</span> c;
00122 }
00123 
00124 <span class="preprocessor">#endif</span>
00125 <span class="preprocessor"></span>
00126 <span class="comment">/*</span>
00127 <span class="comment">/--------------------------------------------------------------------</span>
00128 <span class="comment">|</span>
00129 <span class="comment">|      $Log: plfilterquantize_8h-source.html,v $
00129 <span class="comment">|      Revision 1.4  2004/09/15 15:26:29  uzadow
00129 <span class="comment">|      Linux compatibility changes, doc update.
00129 <span class="comment">|</span>
00130 <span class="comment">|      Revision 1.5  2004/06/15 10:26:13  uzadow</span>
00131 <span class="comment">|      Initial nonfunctioning version of plbmpbase.</span>
00132 <span class="comment">|</span>
00133 <span class="comment">|      Revision 1.4  2002/11/18 14:45:24  uzadow</span>
00134 <span class="comment">|      Added PNG compression support, fixed docs.</span>
00135 <span class="comment">|</span>
00136 <span class="comment">|      Revision 1.3  2002/02/24 13:00:47  uzadow</span>
00137 <span class="comment">|      Documentation update; removed buggy PLFilterRotate.</span>
00138 <span class="comment">|</span>
00139 <span class="comment">|      Revision 1.2  2001/10/06 22:03:26  uzadow</span>
00140 <span class="comment">|      Added PL prefix to basic data types.</span>
00141 <span class="comment">|</span>
00142 <span class="comment">|      Revision 1.1  2001/09/16 19:03:23  uzadow</span>
00143 <span class="comment">|      Added global name prefix PL, changed most filenames.</span>
00144 <span class="comment">|</span>
00145 <span class="comment">|      Revision 1.4  2001/09/15 20:39:57  uzadow</span>
00146 <span class="comment">|      Added Quantization to user-defined palette (Andreas Kpf)</span>
00147 <span class="comment">|</span>
00148 <span class="comment">|      Revision 1.3  2001/01/15 15:05:31  uzadow</span>
00149 <span class="comment">|      Added PLBmp::ApplyFilter() and PLBmp::CreateFilteredCopy()</span>
00150 <span class="comment">|</span>
00151 <span class="comment">|      Revision 1.2  2000/12/18 22:42:53  uzadow</span>
00152 <span class="comment">|      Replaced RGBAPIXEL with PLPixel32.</span>
00153 <span class="comment">|</span>
00154 <span class="comment">|      Revision 1.1  2000/09/26 12:14:49  Administrator</span>
00155 <span class="comment">|      Refactored quantization.</span>
00156 <span class="comment">|</span>
00157 <span class="comment">|</span>
00158 <span class="comment">|</span>
00159 <span class="comment">\--------------------------------------------------------------------</span>
00160 <span class="comment">*/</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Sep 13 16:16:40 2004 for paintlib by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
</a>1.3.2 </small></address>
</body>
</html>