// dibtest // 2006-02-10 #include class CDIB { public: CDIB(); virtual ~CDIB(); int GetWidth() { return m_bmi.bmiHeader.biWidth; } int GetHeight() { return m_bmi.bmiHeader.biHeight; } LPDWORD GetPixelData() { return m_pix; } void Create( int w, int h ); void Kill(); protected: LPDWORD m_pix; //!< フレームバッファ BITMAPINFO m_bmi; }; CDIB::CDIB() { m_pix = NULL; // DIB用BITMAPINFOをクリア ::ZeroMemory( &m_bmi, sizeof(m_bmi) ); } CDIB::~CDIB() { Kill(); } void CDIB::Create( int w, int h ) { if (NULL!=m_pix) return; // DIB用ピクセル列確保 m_pix = (LPDWORD)::HeapAlloc( ::GetProcessHeap(), HEAP_ZERO_MEMORY, w * h * 4 ); // DIB用BITMAPINFOをクリア ::ZeroMemory( &m_bmi, sizeof(m_bmi) ); // DIB用BITMAPINFO設定 m_bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); m_bmi.bmiHeader.biWidth = w; m_bmi.bmiHeader.biHeight = h; m_bmi.bmiHeader.biPlanes = 1; m_bmi.bmiHeader.biBitCount = 32; m_bmi.bmiHeader.biCompression = BI_RGB; } void CDIB::Kill() { if (NULL==m_pix) return; // DIB用ピクセル列解放 ::HeapFree( ::GetProcessHeap(), 0, m_pix ); }