레밍즈프로젝트에서 사용하게 될 그리기 클래스.
TODO. 출력 인터페이스로 상속 받아오기
TODO. 비트맵 정렬 상태 조정 마무리
----
TODO. 출력 인터페이스로 상속 받아오기
TODO. 비트맵 정렬 상태 조정 마무리
----
~cpp #define BITMAP_OPT_HREVERSE 1 #define BITMAP_OPT_VREVERSE 2 #define BITMAP_OPT_HALIGN_CENTER 3 #define BITMAP_OPT_VALIGN_CENTER 4 class CmyDouBuffDC { private: CRect m_rt; CDC* m_pDC; CDC* m_pMemDC; CBitmap m_bmp; //Bitmap Draw Option int m_Vreverse; int m_Hreverse; float m_Valign; float m_Halign; void init(){ resetBmpOpt(); } public: CmyDouBuffDC(CDC *pDC, CRect rt){ init(); m_rt = rt; m_pDC = pDC; m_pMemDC = new CDC(); m_pMemDC->CreateCompatibleDC(m_pDC); m_bmp.CreateCompatibleBitmap(m_pDC, m_rt.Width(), m_rt.Height()); m_pMemDC->SelectObject(&m_bmp); m_pMemDC->Rectangle(0, 0, m_rt.Width(), m_rt.Height()); } ~CmyDouBuffDC(void){ m_pDC->BitBlt(0, 0, m_rt.Width(), m_rt.Height(), m_pMemDC, 0, 0, SRCCOPY); m_pMemDC->DeleteDC(); m_bmp.DeleteObject(); delete m_pMemDC; } CDC* getpMemDC(){return m_pMemDC;} void DrawBmp(UINT ITEM, int x, int y, int kRop=SRCCOPY){ //Load CDC BitMapDC; BitMapDC.CreateCompatibleDC(m_pMemDC); CBitmap newBitmap, *oldBitmap; newBitmap.LoadBitmap(ITEM); oldBitmap = (CBitmap*)BitMapDC.SelectObject(&newBitmap); BITMAP m_bitmapInfo; newBitmap.GetBitmap(&m_bitmapInfo); m_pMemDC->StretchBlt(x-m_bitmapInfo.bmWidth*m_Halign, y-m_bitmapInfo.bmHeight*m_Valign, (m_bitmapInfo.bmWidth)*m_Hreverse, (m_bitmapInfo.bmHeight)*m_Vreverse, &BitMapDC, 0, 0, m_bitmapInfo.bmWidth, m_bitmapInfo.bmHeight, kRop); //회복 BitMapDC.SelectObject(oldBitmap); newBitmap.DeleteObject(); } void setBmpOpt(int kBitMapOption){ switch(kBitMapOption){ case BITMAP_OPT_VALIGN_CENTER: m_Valign = 0.5; break; case BITMAP_OPT_HALIGN_CENTER: m_Halign = 0.5; break; case BITMAP_OPT_HREVERSE: m_Hreverse = -1; break; case BITMAP_OPT_VREVERSE: m_Vreverse = -1; break; } } void resetBmpOpt(){ m_Vreverse=1; m_Hreverse=1; m_Valign=0; m_Halign=0; } void DrawMaskBmp(UINT MASKITEM, UINT IMGITEM, int x, int y){ this->DrawBmp(MASKITEM, x, y, SRCAND); this->DrawBmp(IMGITEM, x, y, SRCPAINT); return; } };