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