StretchBlt

¿øÇü

BOOL StretchBlt(HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, DWORD dwRop);

Àμö

¢ºhDC:ºñÆ®¸ÊÀÌ º¹»çµÉ DC

¢ºX,Y,nWidth,nHeight:ºñÆ®¸ÊÀÌ º¹»çµÉ À§Ä¡ÀÇ Á»ó´Ü ÁÂÇ¥¿Í Æø, ³ÐÀÌ, ÀÌ °ªÀº ³í¸®Àû ÁÂÇ¥°ªÀÌ´Ù.

¢ºHSrcDC:º¹»çµÉ ºñÆ®¸ÊÀ» °¡Áö°í ÀÖ´Â DC. ¸¸¾à dwROP°¡ ¼Ò½º°¡ ÇÊ¿ä¾ø´Â °ªÀ̶ó¸é NULLÀÌ µÉ ¼öµµ ÀÖ´Ù.

¢ºnXOriginSrc,nYOriginSrc, nWidthSrc, nHeightSrc:º¹»çµÉ ºñÆ®¸ÊÀÇ ÁÂÃø »ó´Ü ÁÂÇ¥¿Í Å©±â. ÀÌ ¿µ¿ªÀÇ Å©±â¿Í º¹»çóÀÇ Å©±â°¡ ´Ù¸¦ °æ¿ì ºñÆ®¸ÊÀº º¹»çóÀÇ Å©±â¿¡ ¸Â°Ô Ãà¼ÒµÇ°Å³ª È®´ëµÈ´Ù.

¢ºdwROP:ROPÄÚµå, Áï ºê·¯½¬¿Í º¹»ç¿ø, º¹»çóÀÇ ºñÆ®¸Ê »ö»óÀÌ ³í¸® ¿¬»êµÉ ¹æ¹ýÀ» ÁöÁ¤ÇÑ´Ù. ¸ðµÎ 256°³ÀÇ °¡´ÉÇÑ °ªÀÌ ÀÖÁö¸¸ ½ÇÁ¦·Î Àǹ̸¦ °®´Â ¾øÀº ´ÙÀ½ 15°³ÀÌ¸ç ¸ÅÅ©·Î »ó¼ö°¡ Á¤ÀǵǾî ÀÖ´Ù. ÀÌ ¿ÜÀÇ ROPÄڵ尡 ÇÊ¿äÇÒ °æ¿ì¿¡´Â »ó¼ö¸¦ Á÷Á¢ »ç¿ëÇØ¾ß ÇÑ´Ù. ¾Æ·¡ Ç¥¿¡¼­ S´Â º¹»ç¿ø (Source), D´Â º¹»çó(Destination), P´Â ÆÐÅÏ(Pattern, Áï ºê·¯½¬)¸¦ ÀǹÌÇÑ´Ù.

¸ÅÅ©·Î »ó¼ö »ó¼ö ¿¬»ê½Ä
BLACKNESS 0x00000042 0
DSTINVERT 0x00550009 ~D
MERGECOPY 0x00C000CA D&S
MERGEPAINT 0x00BB0226 ~S|D
NOTSRCCOPY 0x00330008 ~S
NOTSRCERASE 0x001100A6 ~(S|D)
PATCOPY 0x00F00021 P
PATINVERT 0x005A0049 P^D
PATPAINT 0x00FB0A09 P|~(S|D)
SRCAND 0x008800C6 S&D
SRCCOPY 0x00CC0020 S
SRCERASE 0x00440328 S&~D
SRCINVERT 0x00660046 S^D
SRCPAINT 0x00EE0086 S|D
WHITENESS 0x00FF0062 1

¸®ÅÏ ¼º°øÇϸé nonzero, ¿¡·¯ ¹ß»ý½Ã 0À» ¸®ÅÏÇÑ´Ù.
¼³¸í

DC°£¿¡ ºñÆ®¸ÊÀ» Àü¼ÛÇÏ¿© º¹»çÇÑ´Ù. BitBlt¿Í µ¿ÀÛÇÏ´Â ¹æ½ÄÀÌ À¯»çÇϳª ´Ü º¹»ç¿øÀÇ Å©±â¿Í ³ôÀ̸¦ µû·Î ÁöÁ¤ÇÒ ¼ö Àֱ⠶§¹®¿¡ È®´ë¹× Ãà¼Ò º¹»çÇÒ ¼ö ÀÖ´Ù. 20*40ÀÇ Å©±â¸¦ °¡Áö´Â ºñÆ®¸ÊÀ» 40*80¿µ¿ª¿¡ º¹»çÇϸé ÀÌ ºñÆ®¸ÊÀº 2¹è·Î È®´ëµÇ¸ç 10*20¿µ¿ª¿¡ º¹»çÇϸé Àý¹ÝÀ¸·Î Ãà¼ÒµÈ´Ù.

¿¹Á¦ 1

´ÙÀ½ ¿¹Á¦´Â ¸®¼Ò½º¿¡ Á¤ÀÇµÈ IDB_BITMAP1À» µÎ¹è·Î È®´ëÇÏ¿© ÀÛ¾÷ ¿µ¿ª¿¡ Ãâ·ÂÇÑ´Ù.

#include "resource.h"
LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
	HDC hdc;
	PAINTSTRUCT ps;
	HDC MemDC;
	HBITMAP MyBitmap, OldBitmap;
	int bx,by;
	BITMAP bit;

	switch(iMessage) {
	case WM_PAINT:
		hdc=BeginPaint(hWnd, &ps);
		MemDC=CreateCompatibleDC(hdc);
		MyBitmap=LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_BITMAP1));
		OldBitmap=(HBITMAP)SelectObject(MemDC, MyBitmap);

		GetObject(MyBitmap,sizeof(BITMAP),&bit);
		bx=bit.bmWidth;
		by=bit.bmHeight;

		StretchBlt(hdc,0,0,bx*2,by*2,MemDC,0,0,bx,by,SRCCOPY);

		SelectObject(MemDC,OldBitmap);
		DeleteObject(MyBitmap);
		DeleteDC(MemDC);
		EndPaint(hWnd, &ps);
		return 0;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
	return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}

ºñÆ®¸ÊÀÇ Å©±â bx, byº¸´Ù µÎ¹è ´õ ³ÐÀº ¿µ¿ª¿¡ Ãâ·ÂÇßÀ¸¹Ç·Î ºñÆ®¸ÊÀº µÎ¹è·Î È®´ëµÈ´Ù.

´ÙÀ½ ÄÚµå´Â ºñÆ®¸Ê ¿µ¿ªÀÇ Àý¹Ý Å©±âÀÇ ¿µ¿ª¿¡ ºñÆ®¸ÊÀ» Ãâ·ÂÇϹǷΠºñÆ®¸ÊÀÌ Ãà¼ÒµÈ´Ù.

StretchBlt(hdc,0,0,bx/2,by/2,MemDC,0,0,bx,by,SRCCOPY);

ºñÆ®¸ÊÀ» Ãà¼ÒÇÒ ¶§´Â SetStretchBltMode ÇÔ¼ö°¡ ÁöÁ¤ÇÑ ½ºÆ®·¹Äª ¸ðµå¿¡ µû¶ó ȹÀ̳ª ¿­ÀÌ »ý·«µÈ´Ù. ´ÙÀ½ ÄÚµå´Â ºñÆ®¸ÊÀ» ¹Ý´ë·Î µÚÁý´Â´Ù.

StretchBlt(hdc,0,by,bx,-by,MemDC,0,0,bx,by,SRCCOPY);

º¹»ç¿ø°ú º¹»çóÀÇ Å©±â ºÎÈ£°¡ ´Ù¸£¸é °Å¿ï¿¡ ºñÄ£ °Íó·³ ¹Ý»çµÈ ¸ð¾çÀÇ ºñÆ®¸ÊÀÌ Ãâ·ÂµÈ´Ù.

Âü°íÇÔ¼ö BitBlt:ºñÆ®¸ÊÀ» È®´ëÇÏÁö ¾Ê°í Ãâ·ÂÇÑ´Ù.
Ç÷¿Æû95ÀÌ»ó
º»¹®ÂüÁ¶ 

written by http://www.winapi.co.kr