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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
|
<!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: plpixel32.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 Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Compound List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Compound Members</a></div>
<h1>plpixel32.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: plpixel32_8h-source.html,v 1.4 2004/09/15 15:26:32 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">#ifndef INCL_PLPIXEL32</span>
00012 <span class="preprocessor"></span><span class="preprocessor">#define INCL_PLPIXEL32</span>
00013 <span class="preprocessor"></span>
00014 <span class="preprocessor">#include <math.h></span>
00015
00016 <span class="preprocessor">#include "plpixeldefs.h"</span>
00017 <span class="preprocessor">#include "<a class="code" href="plpaintlibdefs_8h.html">plpaintlibdefs.h</a>"</span>
00018 <span class="comment"></span>
00019 <span class="comment">//! 32 bit pixel class. A pixel in this class contains 8 bits each of</span>
00020 <span class="comment">//! red, green, blue and alpha. The order of the color components is</span>
00021 <span class="comment">//! OS-dependent and defined in config.h. This class is meant to be</span>
00022 <span class="comment">//! fast, so all methods are inlined.</span>
<a name="l00023"></a><a class="code" href="classPLPixel32.html">00023</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="classPLPixel32.html">PLPixel32</a>
00024 {
00025 <span class="keyword">public</span>:<span class="comment"></span>
00026 <span class="comment"> //!</span>
00027 <span class="comment"></span> <a class="code" href="classPLPixel32.html">PLPixel32</a> ();<span class="comment"></span>
00028 <span class="comment"> //!</span>
00029 <span class="comment"></span> <a class="code" href="classPLPixel32.html">PLPixel32</a> (PLBYTE r, PLBYTE g, PLBYTE b, PLBYTE a);<span class="comment"></span>
00030 <span class="comment"> //!</span>
00031 <span class="comment"></span> <a class="code" href="classPLPixel32.html">PLPixel32</a> (PLBYTE r, PLBYTE g, PLBYTE b);<span class="comment"></span>
00032 <span class="comment"> //!</span>
00033 <span class="comment"></span> <span class="keywordtype">void</span> Set (PLBYTE r, PLBYTE g, PLBYTE b, PLBYTE a);<span class="comment"></span>
00034 <span class="comment"> //!</span>
00035 <span class="comment"></span> <span class="keywordtype">void</span> Set (PLBYTE r, PLBYTE g, PLBYTE b);<span class="comment"></span>
00036 <span class="comment"> //!</span>
00037 <span class="comment"></span> <span class="keywordtype">void</span> SetR (PLBYTE r);<span class="comment"></span>
00038 <span class="comment"> //!</span>
00039 <span class="comment"></span> <span class="keywordtype">void</span> SetG (PLBYTE g);<span class="comment"></span>
00040 <span class="comment"> //!</span>
00041 <span class="comment"></span> <span class="keywordtype">void</span> SetB (PLBYTE b);<span class="comment"></span>
00042 <span class="comment"> //!</span>
00043 <span class="comment"></span> <span class="keywordtype">void</span> SetA (PLBYTE a);<span class="comment"></span>
00044 <span class="comment"> //!</span>
00045 <span class="comment"></span> PLBYTE GetR () <span class="keyword">const</span>;<span class="comment"></span>
00046 <span class="comment"> //!</span>
00047 <span class="comment"></span> PLBYTE GetG () <span class="keyword">const</span>;<span class="comment"></span>
00048 <span class="comment"> //!</span>
00049 <span class="comment"></span> PLBYTE GetB () <span class="keyword">const</span>;<span class="comment"></span>
00050 <span class="comment"> //!</span>
00051 <span class="comment"></span> PLBYTE GetA () <span class="keyword">const</span>;
00052 <span class="comment"></span>
00053 <span class="comment"> //!</span>
00054 <span class="comment"></span> <span class="keywordtype">bool</span> operator ==(<span class="keyword">const</span> <a class="code" href="classPLPixel32.html">PLPixel32</a> Pix) <span class="keyword">const</span>;
00055 <span class="comment"></span>
00056 <span class="comment"> //!</span>
00057 <span class="comment"></span> <span class="keywordtype">bool</span> operator !=(<span class="keyword">const</span> <a class="code" href="classPLPixel32.html">PLPixel32</a> Pix) <span class="keyword">const</span>;
00058 <span class="comment"></span>
00059 <span class="comment"> //! Simple and fast 'distance' between two pixels. Just adds the</span>
00060 <span class="comment"> //! distances between the color components and treats colors</span>
00061 <span class="comment"> //! equally.</span>
00062 <span class="comment"></span> <span class="keywordtype">int</span> <a class="code" href="classPLPixel32.html#a15">BoxDist</a> (<span class="keyword">const</span> <a class="code" href="classPLPixel32.html">PLPixel32</a> Pix) <span class="keyword">const</span>;
00063 <span class="comment"></span>
00064 <span class="comment"> //! Returns a weighed average between two pixels. Factor must be </span>
00065 <span class="comment"> //! between 0 and 256. Factor=256 means Pix1 is the result, Factor=0 </span>
00066 <span class="comment"> //! means Pix2 is the result.</span>
00067 <span class="comment"></span> <span class="keyword">static</span> <a class="code" href="classPLPixel32.html">PLPixel32</a> <a class="code" href="classPLPixel32.html#e0">Blend</a> (<span class="keywordtype">int</span> Factor, <span class="keyword">const</span> <a class="code" href="classPLPixel32.html">PLPixel32</a> Pix1,
00068 <span class="keyword">const</span> <a class="code" href="classPLPixel32.html">PLPixel32</a> Pix2);
00069
00070 <span class="keyword">private</span>:
00071 PLBYTE m_Data[4];
00072 };
00073
00074 <span class="keyword">inline</span> PLPixel32::PLPixel32()
00075 {
00076 }
00077
00078
00079 <span class="keyword">inline</span> PLPixel32::PLPixel32(PLBYTE r, PLBYTE g, PLBYTE b, PLBYTE a)
00080 {
00081 Set (r, g, b, a);
00082 }
00083
00084
00085 <span class="keyword">inline</span> PLPixel32::PLPixel32(PLBYTE r, PLBYTE g, PLBYTE b)
00086 {
00087 Set (r, g, b, 255);
00088 }
00089
00090
00091 <span class="keyword">inline</span> <span class="keywordtype">void</span> PLPixel32::Set(PLBYTE r, PLBYTE g, PLBYTE b, PLBYTE a)
00092 {
00093 m_Data[PL_RGBA_RED] = r;
00094 m_Data[PL_RGBA_GREEN] = g;
00095 m_Data[PL_RGBA_BLUE] = b;
00096 m_Data[PL_RGBA_ALPHA] = a;
00097 }
00098 <span class="comment"></span>
00099 <span class="comment">//!</span>
00100 <span class="comment"></span><span class="keyword">inline</span> <span class="keywordtype">void</span> PLPixel32::Set (PLBYTE r, PLBYTE g, PLBYTE b)
00101 {
00102 m_Data[PL_RGBA_RED] = r;
00103 m_Data[PL_RGBA_GREEN] = g;
00104 m_Data[PL_RGBA_BLUE] = b;
00105 }
00106
00107 <span class="keyword">inline</span> <span class="keywordtype">void</span> PLPixel32::SetR(PLBYTE r)
00108 {
00109 m_Data[PL_RGBA_RED] = r;
00110 }
00111
00112
00113 <span class="keyword">inline</span> <span class="keywordtype">void</span> PLPixel32::SetG(PLBYTE g)
00114 {
00115 m_Data[PL_RGBA_GREEN] = g;
00116 }
00117
00118
00119 <span class="keyword">inline</span> <span class="keywordtype">void</span> PLPixel32::SetB(PLBYTE b)
00120 {
00121 m_Data[PL_RGBA_BLUE] = b;
00122 }
00123
00124
00125 <span class="keyword">inline</span> <span class="keywordtype">void</span> PLPixel32::SetA(PLBYTE a)
00126 {
00127 m_Data[PL_RGBA_ALPHA] = a;
00128 }
00129
00130
00131 <span class="keyword">inline</span> PLBYTE PLPixel32::GetR()<span class="keyword"> const</span>
00132 <span class="keyword"></span>{
00133 <span class="keywordflow">return</span> m_Data[PL_RGBA_RED];
00134 }
00135
00136
00137 <span class="keyword">inline</span> PLBYTE PLPixel32::GetG()<span class="keyword"> const</span>
00138 <span class="keyword"></span>{
00139 <span class="keywordflow">return</span> m_Data[PL_RGBA_GREEN];
00140 }
00141
00142
00143 <span class="keyword">inline</span> PLBYTE PLPixel32::GetB()<span class="keyword"> const</span>
00144 <span class="keyword"></span>{
00145 <span class="keywordflow">return</span> m_Data[PL_RGBA_BLUE];
00146 }
00147
00148
00149 <span class="keyword">inline</span> PLBYTE PLPixel32::GetA()<span class="keyword"> const</span>
00150 <span class="keyword"></span>{
00151 <span class="keywordflow">return</span> m_Data[PL_RGBA_ALPHA];
00152 }
00153
<a name="l00154"></a><a class="code" href="classPLPixel32.html#a15">00154</a> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="classPLPixel32.html#a15">PLPixel32::BoxDist</a> (<span class="keyword">const</span> <a class="code" href="classPLPixel32.html">PLPixel32</a> Pix)<span class="keyword"> const</span>
00155 <span class="keyword"></span>{
00156 <span class="keywordflow">return</span> (abs ((<span class="keywordtype">int</span>)GetR()-Pix.<a class="code" href="classPLPixel32.html#a9">GetR</a>()) +
00157 abs ((<span class="keywordtype">int</span>)GetG()-Pix.<a class="code" href="classPLPixel32.html#a10">GetG</a>()) +
00158 abs ((<span class="keywordtype">int</span>)GetB()-Pix.<a class="code" href="classPLPixel32.html#a11">GetB</a>()));
00159 }
00160
<a name="l00161"></a><a class="code" href="classPLPixel32.html#e0">00161</a> <span class="keyword">inline</span> <a class="code" href="classPLPixel32.html">PLPixel32</a> <a class="code" href="classPLPixel32.html#e0">PLPixel32::Blend</a> (<span class="keywordtype">int</span> Factor, <span class="keyword">const</span> <a class="code" href="classPLPixel32.html">PLPixel32</a> Pix1, <span class="keyword">const</span> <a class="code" href="classPLPixel32.html">PLPixel32</a> Pix2)
00162 {
00163 PLASSERT (Factor >= 0 && Factor <= 256);
00164
00165 <span class="keywordflow">return</span> <a class="code" href="classPLPixel32.html">PLPixel32</a> ((Pix1.<a class="code" href="classPLPixel32.html#a9">GetR</a>()*Factor+Pix2.<a class="code" href="classPLPixel32.html#a9">GetR</a>()*(256-Factor))>>8,
00166 (Pix1.<a class="code" href="classPLPixel32.html#a10">GetG</a>()*Factor+Pix2.<a class="code" href="classPLPixel32.html#a10">GetG</a>()*(256-Factor))>>8,
00167 (Pix1.<a class="code" href="classPLPixel32.html#a11">GetB</a>()*Factor+Pix2.<a class="code" href="classPLPixel32.html#a11">GetB</a>()*(256-Factor))>>8,
00168 Pix1.<a class="code" href="classPLPixel32.html#a12">GetA</a>());
00169 }
00170
00171 <span class="keyword">inline</span> <span class="keywordtype">bool</span> PLPixel32::operator ==(<span class="keyword">const</span> <a class="code" href="classPLPixel32.html">PLPixel32</a> Pix)<span class="keyword"> const</span>
00172 <span class="keyword"></span>{
00173 <span class="keywordflow">return</span> (*(<span class="keyword">const</span> PLLONG *)<span class="keyword">this</span> == *(<span class="keyword">const</span> PLLONG*)&Pix);
00174 }
00175
00176 <span class="keyword">inline</span> <span class="keywordtype">bool</span> PLPixel32::operator !=(<span class="keyword">const</span> <a class="code" href="classPLPixel32.html">PLPixel32</a> Pix)<span class="keyword"> const</span>
00177 <span class="keyword"></span>{
00178 <span class="keywordflow">return</span> (!(*<span class="keyword">this</span> == Pix));
00179 }
00180
00181
00182 <span class="preprocessor">#endif</span>
00183 <span class="preprocessor"></span>
00184 <span class="comment">/*</span>
00185 <span class="comment">/--------------------------------------------------------------------</span>
00186 <span class="comment">|</span>
00187 <span class="comment">| $Log: plpixel32_8h-source.html,v $
00187 <span class="comment">| Revision 1.4 2004/09/15 15:26:32 uzadow
00187 <span class="comment">| Linux compatibility changes, doc update.
00187 <span class="comment">|</span>
00188 <span class="comment">| Revision 1.7 2002/08/04 20:08:01 uzadow</span>
00189 <span class="comment">| Added PLBmpInfo class, ability to extract metainformation from images without loading the whole image and proper greyscale support.</span>
00190 <span class="comment">|</span>
00191 <span class="comment">| Revision 1.6 2002/03/31 13:36:42 uzadow</span>
00192 <span class="comment">| Updated copyright.</span>
00193 <span class="comment">|</span>
00194 <span class="comment">| Revision 1.5 2001/10/21 17:12:40 uzadow</span>
00195 <span class="comment">| Added PSD decoder beta, removed BPPWanted from all decoders, added PLFilterPixel.</span>
00196 <span class="comment">|</span>
00197 <span class="comment">| Revision 1.4 2001/10/06 22:03:26 uzadow</span>
00198 <span class="comment">| Added PL prefix to basic data types.</span>
00199 <span class="comment">|</span>
00200 <span class="comment">| Revision 1.3 2001/09/28 19:50:56 uzadow</span>
00201 <span class="comment">| Added some 24 bpp stuff & other minor features.</span>
00202 <span class="comment">|</span>
00203 <span class="comment">| Revision 1.2 2001/09/24 14:13:18 uzadow</span>
00204 <span class="comment">| Added Blend, improved const-correctness.</span>
00205 <span class="comment">|</span>
00206 <span class="comment">| Revision 1.1 2001/09/16 19:03:22 uzadow</span>
00207 <span class="comment">| Added global name prefix PL, changed most filenames.</span>
00208 <span class="comment">|</span>
00209 <span class="comment">| Revision 1.3 2001/09/15 14:30:20 uzadow</span>
00210 <span class="comment">| Fixed PLPixel32 initialization bug.</span>
00211 <span class="comment">|</span>
00212 <span class="comment">| Revision 1.2 2001/09/13 20:45:35 uzadow</span>
00213 <span class="comment">| Added 8-bpp pixel class.</span>
00214 <span class="comment">|</span>
00215 <span class="comment">| Revision 1.1 2000/12/18 22:42:52 uzadow</span>
00216 <span class="comment">| Replaced RGBAPIXEL with PLPixel32.</span>
00217 <span class="comment">|</span>
00218 <span class="comment">|</span>
00219 <span class="comment">\--------------------------------------------------------------------</span>
00220 <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>
|