OSDN Git Service

Show Ignore Sub Menu
[tortoisegit/TortoiseGitJp.git] / Utils / MiscUI / DIB.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseSVN\r
4 \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
9 \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
14 \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
18 //\r
19 #pragma once\r
20 \r
21 /**\r
22  * \ingroup Utils\r
23  * \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
28  */\r
29 class CDib : public CObject\r
30 {\r
31 public:\r
32         CDib();\r
33         virtual ~CDib();\r
34 \r
35     /**\r
36      * Clears all member variables and frees allocated memory.\r
37      */\r
38     void                DeleteObject();\r
39     /**\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
43      */\r
44     static int  BytesPerLine(int nWidth, int nBitsPerPixel);\r
45     /**\r
46      * Returns the height of the image in pixels\r
47      */\r
48     int                 GetHeight() const { return m_BMinfo.bmiHeader.biHeight; } \r
49     /**\r
50      * Returns the width of the image in pixels\r
51      */\r
52     int                 GetWidth() const { return m_BMinfo.bmiHeader.biWidth; }\r
53     /**\r
54      * Returns the size of the image in pixels\r
55      */\r
56     CSize               GetSize() const { return CSize(GetWidth(), GetHeight()); }\r
57     /**\r
58      * Returns the image byte field which can be used to work on.\r
59      */\r
60     LPVOID              GetDIBits() { return m_pBits; }\r
61         /**\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
66          */\r
67         void            Create32BitFromPicture (CPictureHolder* pPicture, int iWidth, int iHeight);\r
68 \r
69         /**\r
70          * Returns a 32-bit RGB color\r
71          */\r
72         static COLORREF FixColorRef             (COLORREF clr);\r
73     /**\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
78      */\r
79     BOOL                SetBitmap(const LPBITMAPINFO lpBitmapInfo, const LPVOID lpBits);   \r
80 \r
81 public:\r
82     /**\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
87      */\r
88     BOOL                Draw(CDC* pDC, CPoint ptDest);\r
89 \r
90 protected:\r
91     HBITMAP             m_hBitmap;\r
92     BITMAPINFO  m_BMinfo;\r
93     VOID                *m_pBits;\r
94 };\r
95 \r