비트맵 처리

MFC 2019. 3. 19. 09:59 Posted by 쫀다


CPaintDC dc(this); 

CDC MemDC;

BITMAP bmpInfo;

MemDC.CreateCompatibleDC(&dc);

CBitmap* pOldBmp = NULL;


bmp.LoadBitmap(IDB_BITMAP_BACK);

bmp.GetBitmap(&bmpInfo);

pOldBmp = MemDC.SelectObject(&bmp);

dc.BitBlt(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, &MemDC, 0, 0, SRCCOPY);

::TransparentBlt(dc.m_hDC, 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, MemDC.m_hDC, 0, 0, 

bmpInfo.bmWidth, bmpInfo.bmHeight, RGB(192, 192, 192));


dc.StretchBlt(bmpInfo.bmWidth, 0, bmpInfo.bmWidth * 2, bmpInfo.bmHeight * 2, &MemDC, 

0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, SRCCOPY);

BLENDFUNCTION bf;

bf.BlendOp = AC_SRC_OVER;

bf.BlendFlags = 0;

bf.SourceConstantAlpha = 122;

bf.AlphaFormat = 0;

//반투명 이미지를 출력한다.

::AlphaBlend(pDC->m_hDC,

nW - bmpInfo.bmWidth, nH - bmpInfo.bmHeight,

bmpInfo.bmWidth, bmpInfo.bmHeight,

MemDC.m_hDC,

0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight,

bf);


// 비트맵 파일 로드

HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),

_T("MSN_Back_Alpha.bmp"),

IMAGE_BITMAP, 0, 0,

LR_LOADFROMFILE | LR_CREATEDIBSECTION);

if (hBmp != NULL)

{

::SelectObject(MemDC.m_hDC, hBmp);

dc.BitBlt(0, 0, 147, 164, &MemDC, 0, 0, SRCCOPY);

::DeleteObject(hBmp);

}


MemDC.SelectObject(pOldBmp);