dib.h
资源名称:COM 原理与应用.rar [点击查看]
上传用户:biuytresa
上传日期:2007-12-07
资源大小:721k
文件大小:2k
源码类别:
DNA
开发平台:
Visual C++
- // dib.h declaration for CDib class
- #ifndef _CDIB_H_
- #define _CDIB_H_
- // - This helper class was borrowed and modifed from
- // David Kruglinski's book Inside Visual C++.
- class CDib : public CObject
- {
- enum Alloc {noAlloc, crtAlloc, heapAlloc};
- 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
- 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();
- BOOL AttachMapFile(const char* strPathname, BOOL bShare = FALSE);
- BOOL CopyToMapFile(const char* strPathname);
- BOOL AttachMemory(LPVOID lpvMem, BOOL bMustDelete = FALSE, HGLOBAL hGlobal = NULL);
- BOOL Draw(CDC* pDC, CPoint origin, CSize size); // until we implemnt 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
- HBITMAP CreateBitmap(CDC* pDC);
- BOOL Read(CFile* pFile);
- BOOL ReadSection(CFile* pFile, CDC* pDC = NULL);
- BOOL Write(CFile* pFile);
- void Serialize(CArchive& ar);
- void Empty();
- private:
- void DetachMapFile();
- void ComputePaletteSize(int nBitCount);
- void ComputeMetrics();
- };
- #endif // _CDIB_H_