1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
24 * A wrapper class for DIB's. It provides only a very small
\r
25 * amount of methods (just the ones I need). Especially for
\r
26 * creating 32bit 'image fields' which can be used for
\r
27 * implementing image filters.
\r
29 class CDib : public CObject
\r
36 * Clears all member variables and frees allocated memory.
\r
38 void DeleteObject();
\r
40 * Gets the number of bytes per horizontal line in the image.
\r
41 * \param nWidth the width of the image
\r
42 * \param nBitsPerPixel number of bits per pixel (color depth)
\r
44 static int BytesPerLine(int nWidth, int nBitsPerPixel);
\r
46 * Returns the height of the image in pixels
\r
48 int GetHeight() const { return m_BMinfo.bmiHeader.biHeight; }
\r
50 * Returns the width of the image in pixels
\r
52 int GetWidth() const { return m_BMinfo.bmiHeader.biWidth; }
\r
54 * Returns the size of the image in pixels
\r
56 CSize GetSize() const { return CSize(GetWidth(), GetHeight()); }
\r
58 * Returns the image byte field which can be used to work on.
\r
60 LPVOID GetDIBits() { return m_pBits; }
\r
62 * Creates a DIB from a CPictureHolder object with the specified width and height.
\r
63 * \param pPicture the CPictureHolder object
\r
64 * \param iWidth the width of the resulting picture
\r
65 * \param iHeight the height of the resulting picture
\r
67 void Create32BitFromPicture (CPictureHolder* pPicture, int iWidth, int iHeight);
\r
70 * Returns a 32-bit RGB color
\r
72 static COLORREF FixColorRef (COLORREF clr);
\r
74 * Sets the created Bitmap-image (from Create32BitFromPicture) to the internal
\r
75 * member variables and fills in all required values for this class.
\r
76 * \param lpBitmapInfo a pointer to a BITMAPINFO structure
\r
77 * \param lpBits pointer to the image byte field
\r
79 BOOL SetBitmap(const LPBITMAPINFO lpBitmapInfo, const LPVOID lpBits);
\r
83 * Draws the image on the specified device context at the specified point.
\r
84 * No stretching is done!
\r
85 * \param pDC the device context to draw on
\r
86 * \param ptDest the upper left corner to where the picture should be drawn to
\r
88 BOOL Draw(CDC* pDC, CPoint ptDest);
\r
92 BITMAPINFO m_BMinfo;
\r