Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Dib.h
1 //
2 // Parts of this module were derived from example code in the
3 // 1996 Microsoft Systems Journal, by Paul DiLascia.
4 //
5 
6 #ifndef BEXTRACTOR_DIB_H
7 #define BEXTRACTOR_DIB_H
8 
9 #ifndef _INC_VFW
10 #pragma message ("NOTE: You can speed compilation by including <vfw.h> in stdafx.h")
11 #include <vfw.h>
12 #endif
13 
14 class GDALRasterBand;
15 class GDALDataset;
16 
17 // global functions for ordinary CBitmap too
18 //
19 extern CSize GetBitmapSize(CBitmap* pBitmap);
20 extern BOOL DrawBitmap(CDC& dc, CBitmap* pBitmap,
21  const CRect* rcDst=NULL, const CRect* rcSrc=NULL);
22 
24 // CDib implements Device Independent Bitmaps as a form of CBitmap.
25 //
26 class CDib : public CBitmap
27 {
28 protected:
29  DECLARE_DYNAMIC(CDib)
30  BITMAP m_bm; // stored for speed
31  CPalette m_pal; // palette
32  HDRAWDIB m_hdd; // for DrawDib
33  void *m_data;
34  HBITMAP m_hbm;
35 
36  BITMAPINFOHEADER *m_bmi;
37  RGBQUAD *m_colors;
38  int m_stride;
39 
40 public:
41  CDib();
42  ~CDib();
43 
44  bool Setup(CDC* pDC, int width, int height, int bits_per_pixel,
45  HDRAWDIB hdd, RGBQUAD *colors = NULL);
46 
47  bool Setup(CDC* pDC, GDALDataset *pDataset, HDRAWDIB hdd,
48  bool progress_callback(int) = NULL);
49 
50  CSize GetSize() { return CSize(m_bm.bmWidth, m_bm.bmHeight); }
51  BOOL Attach(HGDIOBJ hbm);
52  BOOL Load(LPCTSTR szPathName);
53  BOOL Load(HINSTANCE hInst, LPCTSTR lpResourceName);
54  BOOL Load(HINSTANCE hInst, UINT uID)
55  { return Load(hInst, MAKEINTRESOURCE(uID)); }
56 
57  // Universal Draw function can use DrawDib or not.
58  BOOL Draw(CDC& dc, const CRect* rcDst=NULL, const CRect* rcSrc=NULL,
59  BOOL bUseDrawDib=TRUE, CPalette* pPal=NULL, BOOL bForeground=FALSE);
60 
61  void GetDIBFromSection();
62  BOOL DeleteObject();
63  BOOL CreatePalette(CPalette& pal);
64  CPalette* GetPalette() { return &m_pal; }
65 
66  UINT GetColorTable(RGBQUAD* colorTab, UINT nColors);
67 
68  void SetPixel24(int x, int y, const RGBQUAD &rgb);
69  void GetPixel24(int x, int y, RGBQUAD &rgb);
70  byte GetPixel8(int x, int y);
71  void SetPixel8(int x, int y, byte val);
72  int GetWidth() { return m_bm.bmWidth; }
73  int GetHeight() { return m_bm.bmHeight; }
74  BITMAPINFOHEADER *GetDIBHeader() { return m_bmi; }
75  char *GetData() { return (char *) m_data; }
76 };
77 
78 CDib *CreateMonoDib(CDC *pDC, CDib *pDib, HDRAWDIB hdd, bool progress_callback(int) = NULL);
79 
80 #endif // BEXTRACTOR_DIB_H