-
Notifications
You must be signed in to change notification settings - Fork 0
/
CDIB.H
75 lines (68 loc) · 2.06 KB
/
CDIB.H
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
// cdib.h
// new version for WIN32
class CDib : public CObject
{
enum Alloc
{
noAlloc,
crtAlloc
}
; // applies to BITMAPINFOHEADER
DECLARE_SERIAL(CDib)
public:
LPVOID m_lpvColorTable;
HBITMAP m_hBitmap;
LPBYTE m_lpImage; // starting address of DIB bits
LPBITMAPINFOHEADER m_lpBMIH; // buffer containing the BITMAPINFOHEADER
LPBITMAPINFOHEADER m_lpBMIH2; // buffer containing the BITMAPINFOHEADER
RGBQUAD rgbTransparent;
RGBQUAD rgbWhite;
RGBQUAD rgbBlack;
private:
HGLOBAL m_hGlobal; // for external windows we need to free
// could be allocated by this class or
// allocated externally
Alloc m_nBmihAlloc;
Alloc m_nImageAlloc;
DWORD m_dwSizeImage; // of bits -- not BITMAPINFOHEADER
// or BITMAPFILEHEADER
int m_nColorTableEntries;
HANDLE m_hFile;
HANDLE m_hMap;
LPVOID m_lpvFile;
HPALETTE m_hPalette;
public:
CDib();
CDib(CSize size, int nBitCount); // builds BITMAPINFOHEADER
~CDib();
int GetSizeImage()
{
return m_dwSizeImage;
}
int GetSizeHeader()
{
return sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * m_nColorTableEntries;
}
CSize GetDimensions();
int GetPixelIndex(int x, int y);
BOOL SetPixelIndex(int x, int y, int iPixel, BOOL bSkip);
BOOL Draw(CDC* pDC, CPoint origin); // until we implement CreateDibSection
BOOL DrawPartial(CDC* pDC, CPoint dest, CPoint source, CSize size); // until we implement CreateDibSection
BOOL DrawTransparent(CDC* pDC, CPoint origin, CSize size); // until we implement CreateDibSection
HBITMAP CreateSection(CDC* pDC = NULL);
UINT UsePalette(CDC* pDC, BOOL bBackground = FALSE);
BOOL MakePalette();
BOOL SetSystemPalette(CDC* pDC);
BOOL Compress(CDC* pDC, BOOL bCompress = TRUE); // FALSE means decompress
BOOL DdbToDib(CDC* pDC, HBITMAP hBitamp);
HBITMAP CreateBitmap(CDC* pDC);
BOOL Read(CFile* pFile);
BOOL Write(CFile* pFile);
void Serialize(CArchive& ar);
void Empty();
BOOL IsEmpty();
private:
void ComputePaletteSize(int nBitCount);
void ComputeMetrics();
}
;