Programming/MFC2010. 6. 27. 18:12


#include <atlimage.h>

void CSaveGrayDemoView::OnRButtonDown(UINT nFlags, CPoint point)
{
// 바탕 화면 윈도우 객체에 대한 포인터를 얻음
CWnd* pWndDesktop = GetDesktopWindow();
CWindowDC ScrDC(pWndDesktop);
CClientDC dc(this);

// 바탕 화면 윈도우의 크기를 알아낸다.
CRect Rect;
pWndDesktop->GetWindowRect(&Rect);

// 바탕 화면 크기 및 색상 수와 동일한 비트맵 이미지를 만든다.
CImage Image;
int cx = Rect.Width();
int cy = Rect.Height();
Image.Create(
cx, cy, ScrDC.GetDeviceCaps(BITSPIXEL));

// 이미지 DC와 화면 DC에 바탕 화면 윈도우 화면을 출력한다.
CDC* pDC = CDC::FromHandle(Image.GetDC());
pDC->BitBlt(0, 0, cx, cy, &ScrDC, 0, 0, SRCCOPY);
dc.BitBlt(0, 0, cx, cy, pDC, 0, 0, SRCCOPY);
Image.ReleaseDC();

// JPEG 형식으로 바탕
 화면 이미지를 저장한다.
Image.Save(_T("Desktop.jpg"), Gdiplus::ImageFormatJPEG);
// 저장된 이미지를 뷰어를 실행하여 보여준다.
::ShellExecute(NULL,
_T("open"), _T("Desktop.jpg"),
NULL, NULL, SW_SHOW);

CView::OnRButtonDown(nFlags, point);
}

'Programming > MFC' 카테고리의 다른 글

비트맵 및 이미지 처리 - 흑백 변환  (1) 2010.06.27
비트맵과 이미지 처리  (1) 2010.06.22
Posted by zzibong