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 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
|
<!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: plwinbmp.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>plwinbmp.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: plwinbmp_8h-source.html,v 1.2 2004/09/15 15:26:32 uzadow Exp $</span>
00005 <span class="comment">|</span>
00006 <span class="comment">| Copyright (c) 1996-1998 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_WINBMP</span>
00012 <span class="preprocessor"></span><span class="preprocessor">#define INCL_WINBMP</span>
00013 <span class="preprocessor"></span>
00014 <span class="preprocessor">#ifndef INCL_PLBITMAP</span>
00015 <span class="preprocessor"></span><span class="preprocessor">#include "plbitmap.h"</span>
00016 <span class="preprocessor">#endif</span>
00017 <span class="preprocessor"></span>
00018 <span class="preprocessor">#ifdef _WINDOWS</span>
00019 <span class="preprocessor"></span><span class="preprocessor"> #define WIN32_LEAN_AND_MEAN </span><span class="comment">/* Prevent including <winsock*.h> in <windows.h> */</span>
00020 <span class="preprocessor"> #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers</span>
00021 <span class="preprocessor"></span><span class="preprocessor"> #include <windows.h></span>
00022 <span class="preprocessor">#endif</span>
00023 <span class="preprocessor"></span><span class="comment"></span>
00024 <span class="comment">//! This is the windows version of PLBmp. The internal storage format</span>
00025 <span class="comment">//! is a windows DIB. It supports all color depths allowed by</span>
00026 <span class="comment">//! windows: 1, 8, 16, 24, and 32 bpp. </span>
00027 <span class="comment">//!</span>
00028 <span class="comment">//! The subset of the windows DIB format supported is as follows: The</span>
00029 <span class="comment">//! DIB is stored so that header, palette, and bits are in one</span>
00030 <span class="comment">//! buffer. The bottom line is stored first (biHeight must be > 0)</span>
00031 <span class="comment">//! and the data is uncompressed (BI_RGB). Color tables for 16, 24,</span>
00032 <span class="comment">//! and 32 bpp are not supported. biClrUsed is always 0. The palette</span>
00033 <span class="comment">//! mode is DIB_RGB_COLORS. DIB_PAL_COLORS is not supported.</span>
00034 <span class="comment">//!</span>
00035 <span class="comment">//! Note that almost all real-life DIBs conform to this subset</span>
00036 <span class="comment">//! anyway, so there shouldn't be any problems.</span>
00037 <span class="comment">//!</span>
00038 <span class="comment">//! <i>In the current version, some functions (notably CreateCopy) only</span>
00039 <span class="comment">//! support 1, 8 and 32 bpp. Sorry!</i></span>
<a name="l00040"></a><a class="code" href="classPLWinBmp.html">00040</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="classPLWinBmp.html">PLWinBmp</a> : <span class="keyword">public</span> <a class="code" href="classPLBmp.html">PLBmp</a>
00041 {
00042
00043 <span class="keyword">public</span>:
00044 <span class="comment">// Creates an empty bitmap.</span>
00045 <a class="code" href="classPLWinBmp.html#a1">PLWinBmp</a> ();
00046 <span class="comment"></span>
00047 <span class="comment"> //! Copy constructor</span>
00048 <span class="comment"></span> <a class="code" href="classPLWinBmp.html">PLWinBmp</a>
00049 ( <span class="keyword">const</span> <a class="code" href="classPLWinBmp.html">PLWinBmp</a> &Orig
00050 );
00051 <span class="comment"></span>
00052 <span class="comment"> //! Copy constructor</span>
00053 <span class="comment"></span> <a class="code" href="classPLWinBmp.html">PLWinBmp</a>
00054 ( <span class="keyword">const</span> <a class="code" href="classPLBmpBase.html">PLBmpBase</a> &Orig
00055 );
00056 <span class="comment"></span>
00057 <span class="comment"> //! Destroys the bitmap.</span>
00058 <span class="comment"></span> <span class="keyword">virtual</span> <a class="code" href="classPLWinBmp.html#a3">~PLWinBmp</a> ();
00059 <span class="comment"></span>
00060 <span class="comment"> //! Assignment operator.</span>
00061 <span class="comment"></span> <a class="code" href="classPLWinBmp.html">PLWinBmp</a> &<a class="code" href="classPLWinBmp.html#a4">operator= </a>(<a class="code" href="classPLBmpBase.html">PLBmpBase</a> <span class="keyword">const</span> &Orig);
00062 <span class="comment"></span>
00063 <span class="comment"> //! Assignment operator.</span>
00064 <span class="comment"></span> <a class="code" href="classPLWinBmp.html">PLWinBmp</a> &<a class="code" href="classPLWinBmp.html#a4">operator= </a>(<a class="code" href="classPLWinBmp.html">PLWinBmp</a> <span class="keyword">const</span> &Orig);
00065
00066 <span class="preprocessor">#ifdef _DEBUG</span>
00067 <span class="preprocessor"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> AssertValid () <span class="keyword">const</span>; <span class="comment">// Tests internal object state</span>
00068 <span class="preprocessor">#endif</span>
00069 <span class="preprocessor"></span>
00070 <span class="comment">// PLWinBmp manipulation</span>
00071
00072 <span class="comment">// Do a bitblt using the alpha channel of pSrPLBmp. Restricted to</span>
00073 <span class="comment">// 32 bpp.</span>
00074 <span class="comment">// Legacy routine. Use the Blt classes instead.</span>
00075 <span class="keywordtype">void</span> AlphaBlt (<a class="code" href="classPLWinBmp.html">PLWinBmp</a> * pSrPLBmp, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y);
00076
00077 <span class="comment">// PLWinBmp information</span>
00078 <span class="comment"></span>
00079 <span class="comment"> //! Returns the amount of memory used by the object.</span>
00080 <span class="comment"></span> <span class="keyword">virtual</span> <span class="keywordtype">long</span> <a class="code" href="classPLWinBmp.html#a7">GetMemUsed</a> ();
00081 <span class="comment"></span>
00082 <span class="comment"> //! Returns number of bytes used per line.</span>
00083 <span class="comment"></span> <span class="keyword">virtual</span> <span class="keywordtype">long</span> <a class="code" href="classPLWinBmp.html#a8">GetBytesPerLine</a> ();
00084
00085 <span class="comment">// Windows-specific interface</span>
00086 <span class="comment"></span>
00087 <span class="comment"> //! Loads a bitmap from a windows resource (.rc or .res linked to</span>
00088 <span class="comment"> //! the exe). Fails if the bitmap is compressed.</span>
00089 <span class="comment"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classPLWinBmp.html#a9">CreateRes</a> (HINSTANCE lh_ResInst, <span class="keywordtype">int</span> ID);
00090 <span class="comment"></span>
00091 <span class="comment"> //! Takes a HBITMAP and converts it to a PLWinBmp.</span>
00092 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classPLWinBmp.html#a10">CreateFromHBitmap</a> (HBITMAP hBitMap);
00093 <span class="comment"></span>
00094 <span class="comment"> //! Takes an existing device-independent bitmap and converts it</span>
00095 <span class="comment"> //! to a PLWinBmp.</span>
00096 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classPLWinBmp.html#a11">CreateFromHDIBBitmap</a>(BITMAPINFOHEADER* pBIH, HPALETTE hPal = NULL);
00097 <span class="comment"></span>
00098 <span class="comment"> //! Returns the size of the bitmap in pixels</span>
00099 <span class="comment"></span> SIZE <a class="code" href="classPLWinBmp.html#a12">GetSize</a> ();
00100 <span class="comment"></span>
00101 <span class="comment"> //! Access the windows bitmap structure. Using this structure, all</span>
00102 <span class="comment"> //! standard DIB manipulations can be performed.</span>
00103 <span class="comment"></span> BITMAPINFOHEADER * <a class="code" href="classPLWinBmp.html#a13">GetBMI</a> ();
00104
00105 <span class="comment">// PLWinBmp output</span>
00106 <span class="comment"></span>
00107 <span class="comment"> //! Draws the bitmap on the given device context using</span>
00108 <span class="comment"> //! StretchDIBits.</span>
00109 <span class="comment"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classPLWinBmp.html#a14">Draw</a> (HDC hDC, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, DWORD rop = SRCCOPY);
00110 <span class="comment"></span>
00111 <span class="comment"> //! Draws the bitmap on the given device context using</span>
00112 <span class="comment"> //! StretchDIBits. Scales the bitmap by Factor.</span>
00113 <span class="comment"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classPLWinBmp.html#a15">StretchDraw</a> (HDC hDC, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">double</span> Factor, DWORD rop = SRCCOPY);
00114 <span class="comment"></span>
00115 <span class="comment"> //! Draws the bitmap on the given device context using</span>
00116 <span class="comment"> //! StretchDIBits. Scales the bitmap so w is the width and</span>
00117 <span class="comment"> //! h the height.</span>
00118 <span class="comment"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classPLWinBmp.html#a15">StretchDraw</a> (HDC hDC, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h, DWORD rop = SRCCOPY);
00119 <span class="comment"></span>
00120 <span class="comment"> //! Draws a portion of the bitmap on the given device context</span>
00121 <span class="comment"></span> <span class="keyword">virtual</span> BOOL <a class="code" href="classPLWinBmp.html#a17">DrawExtract</a> (HDC hDC, POINT pntDest, RECT rcSrc);
00122 <span class="comment"></span>
00123 <span class="comment"> //! Puts a copy of the bitmap in the clipboard</span>
00124 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classPLWinBmp.html#a18">ToClipboard</a> ();
00125 <span class="comment"></span>
00126 <span class="comment"> //! Reads the clipboard into the bitmap. uFormat can be either</span>
00127 <span class="comment"> //! CF_BITMAP or CF_DIB.</span>
00128 <span class="comment"></span> <span class="keywordtype">bool</span> <a class="code" href="classPLWinBmp.html#a19">FromClipboard</a> (UINT uFormat = CF_BITMAP);
00129 <span class="comment"></span>
00130 <span class="comment"> //! Gets a pointer to the bitmap bits. (Usually, using GetLineArray()</span>
00131 <span class="comment"> //! is much easier!)</span>
00132 <span class="comment"></span> BYTE * <a class="code" href="classPLWinBmp.html#a20">GetBits</a> ();
00133 <span class="comment"></span>
00134 <span class="comment"> //! Copies the palette over from pSrPLBmp.</span>
00135 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classPLWinBmp.html#a21">CopyPalette</a> (<a class="code" href="classPLWinBmp.html">PLWinBmp</a> * pSrPLBmp);
00136 <span class="comment"></span>
00137 <span class="comment"> //! Traces the values in the palette via PLTRACE();</span>
00138 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classPLWinBmp.html#a22">TracePalette</a>();
00139
00140 <span class="comment">// Static functions</span>
00141 <span class="comment"></span>
00142 <span class="comment"> //! Returns memory needed by a bitmap with the specified attributes.</span>
00143 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">long</span> <a class="code" href="classPLWinBmp.html#e0">GetMemNeeded</a> (LONG width, LONG height, WORD BitsPerPixel);
00144 <span class="comment"></span>
00145 <span class="comment"> //! Returns memory needed by bitmap bits.</span>
00146 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">long</span> <a class="code" href="classPLWinBmp.html#e1">GetBitsMemNeeded</a> (LONG width, LONG height, WORD BitsPerPixel);
00147 <span class="comment"></span>
00148 <span class="comment"> //! Returns memory needed by one line.</span>
00149 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classPLWinBmp.html#e2">GetLineMemNeeded</a> (LONG width, WORD BitsPerPixel);
00150
00151 <span class="keyword">protected</span>:
00152
00153 <span class="comment">// Protected callbacks</span>
00154 <span class="comment"></span>
00155 <span class="comment"> //! Create a new empty DIB. Bits are uninitialized.</span>
00156 <span class="comment"> //! Assumes that no memory is allocated before the call.</span>
00157 <span class="comment"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classPLWinBmp.html#b0">internalCreate</a> (LONG Width, LONG Height,
00158 <span class="keyword">const</span> PLPixelFormat& pf);
00159 <span class="comment"></span>
00160 <span class="comment"> //! Creates a PLWinBmp from an existing bitmap pointer.</span>
00161 <span class="comment"> //! Assumes that no memory is allocated before the call.</span>
00162 <span class="comment"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classPLWinBmp.html#b0">internalCreate</a> (BITMAPINFOHEADER* pBMI);
00163 <span class="comment"></span>
00164 <span class="comment"> //! Deletes memory allocated by member variables.</span>
00165 <span class="comment"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classPLWinBmp.html#b2">freeMembers</a> ();
00166 <span class="comment"></span>
00167 <span class="comment"> //! Initializes internal table of line addresses.</span>
00168 <span class="comment"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classPLWinBmp.html#b3">initLineArray</a> ();
00169
00170 <span class="comment">// Creates a copy of the current bitmap in a global memory block</span>
00171 <span class="comment">// and returns a handle to this block.</span>
00172 <span class="keyword">virtual</span> HANDLE createCopyHandle ();
00173
00174 <span class="comment">// Set color table pointer & pointer to bits based on m_pBMI.</span>
00175 <span class="keyword">virtual</span> <span class="keywordtype">void</span> initPointers ();
00176
00177 <span class="keyword">const</span> PLPixelFormat& pixelFormatFromBMI(<span class="keyword">const</span> BITMAPINFOHEADER * pBMI) <span class="keyword">const</span>;
00178
00179 <span class="comment">// Member variables.</span>
00180
00181 BITMAPINFOHEADER * m_pBMI; <span class="comment">// Pointer to picture format information.</span>
00182 BYTE * m_pBits;
00183
00184
00185 <span class="keyword">private</span>:
00186 };
00187
00188
00189 <span class="comment">// Note that _both_ these copy constructors are needed. If only the </span>
00190 <span class="comment">// second one is there, the compiler generates a default copy </span>
00191 <span class="comment">// constructor anyway :-(.</span>
00192 <span class="keyword">inline</span> PLWinBmp::PLWinBmp
<a name="l00193"></a><a class="code" href="classPLWinBmp.html#a1">00193</a> ( <span class="keyword">const</span> <a class="code" href="classPLWinBmp.html">PLWinBmp</a> &Orig
00194 )
00195 : <a class="code" href="classPLBmp.html">PLBmp</a> ()
00196 {
00197 internalCopy (Orig);
00198 }
00199
00200 <span class="keyword">inline</span> PLWinBmp::PLWinBmp
<a name="l00201"></a><a class="code" href="classPLWinBmp.html#a2">00201</a> ( <span class="keyword">const</span> <a class="code" href="classPLBmpBase.html">PLBmpBase</a> &Orig
00202 )
00203 : <a class="code" href="classPLBmp.html">PLBmp</a> ()
00204 {
00205 internalCopy (Orig);
00206 }
00207
<a name="l00208"></a><a class="code" href="classPLWinBmp.html#a4">00208</a> <span class="keyword">inline</span> <a class="code" href="classPLWinBmp.html">PLWinBmp</a> & <a class="code" href="classPLWinBmp.html#a4">PLWinBmp::operator= </a>( <a class="code" href="classPLBmpBase.html">PLBmpBase</a> <span class="keyword">const</span> &Orig)
00209 {
00210 <a class="code" href="classPLBmp.html#a2">PLBmp::operator=</a>(Orig);
00211 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
00212 }
00213
<a name="l00214"></a><a class="code" href="classPLWinBmp.html#a5">00214</a> <span class="keyword">inline</span> <a class="code" href="classPLWinBmp.html">PLWinBmp</a> & <a class="code" href="classPLWinBmp.html#a4">PLWinBmp::operator= </a>( <a class="code" href="classPLWinBmp.html">PLWinBmp</a> <span class="keyword">const</span> &Orig)
00215 {
00216 <a class="code" href="classPLBmp.html#a2">PLBmp::operator=</a>(Orig);
00217 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
00218 }
00219
00220
00221 <span class="preprocessor">#endif</span>
00222 <span class="preprocessor"></span><span class="comment">/*</span>
00223 <span class="comment">/--------------------------------------------------------------------</span>
00224 <span class="comment">|</span>
00225 <span class="comment">| $Log: plwinbmp_8h-source.html,v $
00225 <span class="comment">| Revision 1.2 2004/09/15 15:26:32 uzadow
00225 <span class="comment">| Linux compatibility changes, doc update.
00225 <span class="comment">|</span>
00226 <span class="comment">| Revision 1.6 2004/09/11 14:15:40 uzadow</span>
00227 <span class="comment">| Comitted testimages, resized most of them.</span>
00228 <span class="comment">|</span>
00229 <span class="comment">| Revision 1.5 2004/09/09 16:52:50 artcom</span>
00230 <span class="comment">| refactored PixelFormat</span>
00231 <span class="comment">|</span>
00232 <span class="comment">| Revision 1.4 2004/06/15 14:17:25 uzadow</span>
00233 <span class="comment">| First working version of PLSubBmp.</span>
00234 <span class="comment">|</span>
00235 <span class="comment">| Revision 1.3 2003/08/03 12:03:22 uzadow</span>
00236 <span class="comment">| Added unicode support; fixed some header includes.</span>
00237 <span class="comment">|</span>
00238 <span class="comment">| Revision 1.2 2002/08/04 20:08:01 uzadow</span>
00239 <span class="comment">| Added PLBmpInfo class, ability to extract metainformation from images without loading the whole image and proper greyscale support.</span>
00240 <span class="comment">|</span>
00241 <span class="comment">| Revision 1.1 2001/09/16 19:03:23 uzadow</span>
00242 <span class="comment">| Added global name prefix PL, changed most filenames.</span>
00243 <span class="comment">|</span>
00244 <span class="comment">| Revision 1.14 2001/01/14 13:36:15 uzadow</span>
00245 <span class="comment">| Added PLAnyPicDecoder::GetFileFormat()</span>
00246 <span class="comment">|</span>
00247 <span class="comment">| Revision 1.13 2000/11/21 20:29:39 uzadow</span>
00248 <span class="comment">| Added test project.</span>
00249 <span class="comment">|</span>
00250 <span class="comment">| Revision 1.12 2000/11/02 21:28:47 uzadow</span>
00251 <span class="comment">| Fixed copy constructors.</span>
00252 <span class="comment">|</span>
00253 <span class="comment">| Revision 1.11 2000/10/12 21:59:34 uzadow</span>
00254 <span class="comment">| Added CreateFromHDIBBitmap() and CopyPalette() to PLWinBmp</span>
00255 <span class="comment">| Added CF_DIB support to PLWinBmp::FromClipboard() (Richard Hollis)</span>
00256 <span class="comment">|</span>
00257 <span class="comment">| Revision 1.10 2000/09/01 14:13:49 Administrator</span>
00258 <span class="comment">| Removed MFC from paintX, added MSCV paintX sample.</span>
00259 <span class="comment">|</span>
00260 <span class="comment">| Revision 1.9 2000/08/13 12:11:43 Administrator</span>
00261 <span class="comment">| Added experimental DirectDraw-Support</span>
00262 <span class="comment">|</span>
00263 <span class="comment">| Revision 1.8 2000/01/17 23:37:12 Ulrich von Zadow</span>
00264 <span class="comment">| Corrected bug in assignment operator.</span>
00265 <span class="comment">|</span>
00266 <span class="comment">| Revision 1.7 2000/01/16 20:43:18 anonymous</span>
00267 <span class="comment">| Removed MFC dependencies</span>
00268 <span class="comment">|</span>
00269 <span class="comment">| Revision 1.6 2000/01/10 23:53:01 Ulrich von Zadow</span>
00270 <span class="comment">| Changed formatting & removed tabs.</span>
00271 <span class="comment">|</span>
00272 <span class="comment">\--------------------------------------------------------------------</span>
00273 <span class="comment">*/</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Sep 13 16:16:41 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>
|