화면 DC에 있는 색상들을 메모리 DC로 옮길 수 있나요?
글쓴이: mydream / 작성시간: 월, 2015/08/31 - 7:21오후
화면 DC에 있는 색상들의 일부를 메모리 DC로 옮기려고 시도해봤는데, 잘 안되네요. 어떻게 해야 화면 DC 일부를 메모리 DC로 가져올 수 있을까요? 그리고 그 메모리 DC를 다시 화면 DC로 옮기려고 하는데요. 그것 역시 잘 안됩니다.
#include <windows.h>
LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
int APIENTRY WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd);
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
WNDCLASS WndCls;
WndCls.cbClsExtra=0;
WndCls.cbWndExtra=0;
WndCls.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
WndCls.hCursor=LoadCursor(NULL, IDC_ARROW);
WndCls.hIcon=NULL;
WndCls.hInstance=hInstance;
WndCls.lpfnWndProc=WinProc;
WndCls.lpszClassName=TEXT("copy");
WndCls.lpszMenuName=NULL;
WndCls.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&WndCls);
HWND hwnd=CreateWindow(TEXT("copy"), TEXT("win"), WS_OVERLAPPEDWINDOW, 300, 300, 500, 500, NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, nShowCmd);
MSG message;
while( GetMessage(&message, NULL, 0, 0) ) {
TranslateMessage(&message);
DispatchMessage(&message);
}
return message.wParam;
}
LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
switch(message) {
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_KEYDOWN:
switch(wparam) {
case VK_LEFT:
HDC hdc=GetDC(hwnd);
HDC memDC=CreateCompatibleDC(hdc);
StretchBlt(memDC, 0, 0, 200, 200, hdc, 0, 0, 200, 200, SRCCOPY);
StretchBlt(hdc, 200, 200, 200, 200, memDC, 0, 0, 200, 200, SRCCOPY);
//위 두 줄의 코드에서 복사가 제대로 안됩니다.
DeleteDC(memDC);
ReleaseDC(hwnd, hdc);
break;
}
return 0;
case WM_PAINT:
PAINTSTRUCT pst;
HDC hdc=BeginPaint(hwnd, &pst);
HBRUSH new_brush=CreateSolidBrush(0x000000);
HBRUSH backup_brush=(HBRUSH)SelectObject(hdc, new_brush);
Rectangle(hdc, 0, 0, 200, 200);
SelectObject(hdc, backup_brush);
DeleteObject(new_brush);
EndPaint(hwnd, &pst);
return 0;
}
return DefWindowProc(hwnd, message, wparam, lparam);
}Forums:


여기서 검색하시면
여기서 검색하시면 됩니다.
http://www.devpia.com/
http://soen.kr/
Written By the Black Knight of Destruction
댓글 달기