summaryrefslogtreecommitdiff
path: root/plugins/NewStory/src/dib.h
blob: 62e6051d9e2c6316d5d4004dd60b54278c65f85e (plain)
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
#pragma once

namespace simpledib
{
	class dib
	{
		HBITMAP   m_bmp;
		HBITMAP   m_oldBmp;
		HDC       m_hdc;
		LPRGBQUAD m_bits;
		int       m_width, m_height;

		HDC       m_hTargetDC;
		POINT     m_oldViewPort;
		bool      m_restore_view_port = false, m_ownData = false;
		RECT      m_rcTarget;
	
	public:
		dib();
		~dib();

		__forceinline int width() const { return m_width; }
		__forceinline int height() const { return m_height; }
		__forceinline HDC hdc()	const { return m_hdc; }
		__forceinline HBITMAP bmp() const { return m_bmp; }
		__forceinline LPRGBQUAD	bits() const { return m_bits; }
		__forceinline operator HDC() { return m_hdc; }

		bool create(int width, int height, bool topdowndib = false);
		bool create(HDC hdc, HBITMAP bmp, LPRGBQUAD bits, int width, int height);

		void clear();
		void destroy(bool del_bmp = true);
		void draw(HDC hdc, int x, int y);
		void draw(HDC hdc, LPRECT rcDraw);
		HDC  beginPaint(HDC hdc, LPRECT rcDraw);
		void endPaint(bool copy = false);
		HBITMAP detach_bitmap();
	};
}