|
´ÙÀ̾î·Î±× ¹Ú½º¿¡ ºñÆ®¸ã ±×·¡ÇÈ ±×¸®±â |
|||||
ÇнÀ¸ñÇ¥ |
||||||
¾Ö´Ï¸ÞÀÌ¼Ç ÇÁ·Î±×·¥ÀÇ Áغñ °úÁ¤À¸·Î ±×·¡ÇÈ ÆÄÀÏÀ» ¿Ã¸®°í È®´ë Ãà¼ÒÇÏ´Â ¹æ¹ýÀ» ¹è¿î´Ù. |
||||||
ÇнÀÁÖÁ¦ |
||||||
ÀÌÀåÀº ÇлýµéÀÇ Èï¹Ì¸¦ ÀÏÀ¸Å°±â À§ÇÑ ´Ü¿øÀ¸·Î °ÔÀÓ¿¡ °ü½É ÀÖ´Â Çлýµé¿¡°Ô ¾Ö´Ï¸ÞÀÌ¼Ç Á¦ÀÛÀÇ ±âÃÊ °úÁ¤À» °øºÎ ÇÕ´Ï´Ù. 1. ºñÆ®¸Ê ±×·¡ÇÈ º¸±â 2. ±×¸²ÀÇ Ãà¼Ò¿Í È®´ë |
|
|||||
¿¹½À³»¿ë |
||||||
¾Ö´Ï¸ÞÀÌ¼Ç °úÁ¤Àº ¡°VISUAL C++ 6,±è¿ë¼º,¿µÁøÃâÆǻ硱ÀÇ ³»¿ë(P573~P593)À» °¡Áö°í ¼ö¾÷ ÇÕ´Ï´Ù. ÀÚ¼¼ÇÑ ³»¿ëÀº ÀÌ Ã¥À» ÂüÁ¶ Çϼ¼¿ä. |
||||||
½Ç½À¹æ¹ý |
||||||
¸ñ Â÷ |
||||||
1. ºñÆ®¸ãÀÇ Ãâ·Â´ÙÀ½°ú °°ÀÌ ÇÁ·ÎÁ§Æ®¸¦ ¸¸µç´Ù.
¾Æ·¡¿Í °°ÀÌ ¼±ÅÃÇÏ¿© ÇÁ·Î±×·¥À» ¿¬´Ù. |
||||||
|
|
|||||
man.bmp¡± ÆÄÀÏÀ» BMP.dsw¿¡ ÀÖ´Â ¡°res¡± µð·ºÅ丮·Î º¹»ç¸¦ ÇÑ´Ù. ¾Æ·¡¿Í °°ÀÌ ±×¸² ÆÄÀÏÀÌ º¹»çµÈ °ÍÀ» È®ÀÎ ÇÑ´Ù.
|
||||||
|
°¡Á®¿À±â¸¦ ¼±ÅÃÇÑ´Ù.
|
|||||
¸¶¿ì½º·Î ¡°man¡±±×¸² ÆÄÀÏÀ» ¼±ÅÃÇÏ°í ¡°¿±â¡±¸¦ ¼±ÅÃÇÑ´Ù. |
||||||
±×¸²°ú °°ÀÌ ±×¸²ÀÌ µé¾î¿Â °ÍÀ» º¼ ¼ö ÀÖ´Ù.
|
||||||
¸¶¿ì½º ¿À¸¥ÂÊ ¹öÆ°À» ´·¯ ¼Ó¼ºÀ» ¼±ÅÃÇÏ°í
ID¸¦ ¡°IDB_MAN¡±À¸·Î ¼öÁ¤ÇÑ´Ù.
|
|
|||||
±×¸²°ú °°ÀÌ ¹öÆ°À» ¸¸µç´Ù.
|
||||||
¡°Caption¡±À» ¡°±×¸² ±×¸®±â¡±·Î °íÄ¡°í ¼Ó¼º¿¡¼ ¾Æ·¡¿Í °°ÀÌ ÇÔ¼ö¸¦ Ãß°¡ÇÑ´Ù.
|
||||||
´ÙÀ½°ú °°ÀÌ ¡°CBmpDlg¡± Ŭ·¡½º¿¡ ¡°ÇÔ¼öÃß°¡¡±¸¦ ¼±ÅÃÇÑ´Ù.
|
||||||
¡°DrawBitmap¡± ÇÔ¼ö¸¦
void ÇüÅ·Π¸¸µç´Ù.
|
||||||
ÇÔ¼ö¿¡ ¾Æ·¡¿Í °°ÀÌ ÇÁ·Î±×·¥À» Ãß°¡ÇÑ´Ù.
|
||||||
|
void CBmpDlg::DrawBitmap(void) { CClientDC pDc(this); CDC
MemDC; MemDC.CreateCompatibleDC(&pDc); //
¸®¼Ò½º¿¡¼ºñÆ®¸ÊÀ»Àоîµé¿©DC¿¡¼±Åà CBitmap
bitmap; bitmap.
LoadBitmap(IDB_MAN); CBitmap
*pOldBitmap = (CBitmap *)MemDC.SelectObject(&bitmap); //
ºñÆ®¸Êºí·ÏÀü¼Û pDc.BitBlt(50,
50, 128, 32, &MemDC, 0, 0, SRCCOPY); //
DC º¹¿ø MemDC.SelectObject(pOldBitmap); } void CBmpDlg::OnBnClickedButton1() { // TODO: ¿©±â¿¡ÄÁÆ®·Ñ¾Ë¸²Ã³¸®±âÄڵ带Ãß°¡ÇÕ´Ï´Ù. DrawBitmap(); } |
|
||||
¹öÆ°À» ´©¸£¸é ±×¸²°ú °°ÀÌ ±×¸²ÀÌ Ãâ·ÂµÇ´Â °ÍÀ» º¼ ¼ö ÀÖ´Ù.
|
||||||
È®´ë ´ëĪ À̵¿ ±×¸²À» ±×¸®±â À§ÇØ ¡°DrawBitmap¡± ÇÔ¼ö¸¦ ¼öÁ¤ÇÑ´Ù.
|
||||||
|
void CBmpDlg::DrawBitmap(void) { CClientDC pDc(this); CDC
MemDC; MemDC.CreateCompatibleDC(&pDc); //
¸®¼Ò½º¿¡¼ºñÆ®¸ÊÀ»Àоîµé¿©DC¿¡¼±Åà CBitmap
bitmap; bitmap.
LoadBitmap(IDB_MAN); CBitmap
*pOldBitmap = (CBitmap *)MemDC.SelectObject(&bitmap); //
ºñÆ®¸Êºí·ÏÀü¼Û pDc.BitBlt(50,
50, 128, 32, &MemDC, 0, 0, SRCCOPY); //
Á¿ì¹æÇâÀüȯ pDc.StretchBlt(100,
150, 32, 32, &MemDC, 32, 0, -32, 32, SRCCOPY); //
»óÇÏÁ¿ì·ÎµÚÁý¾îÃâ·Â pDc.StretchBlt(150,
150, 32, 32, &MemDC, 32, 32, -32, -32, SRCCOPY); //
2¹èÈ®´ëÇÏ¿©Ãâ·Â pDc.StretchBlt(200,
150, 64, 64, &MemDC, 0, 0, 32, 32, SRCCOPY); //
DC º¹¿ø MemDC.SelectObject(pOldBitmap); }
|
|
||||
|
||||||
|
||||||
°ú Á¦ |
||||||
|
||||||
CDC::BitBlt
BOOL BitBlt( int x,
int y, int nWidth, int nHeight,
CDC* pSrcDC, int xSrc, int ySrc,
DWORD dwRop ); Return
Value Nonzero
if the function is successful; otherwise 0. Parameters x Specifies
the logical x-coordinate of the upper-left corner of the destination
rectangle. y Specifies
the logical y-coordinate of the upper-left corner of the destination
rectangle. nWidth Specifies
the width (in logical units) of the destination rectangle and source bitmap. nHeight Specifies
the height (in logical units) of the destination rectangle and source bitmap. pSrcDC Pointer
to a CDC object that identifies the device context from which the
bitmap will be copied. It must be NULL if dwRop specifies a
raster operation that does not include a source. xSrc Specifies
the logical x-coordinate of the upper-left corner of the source bitmap. ySrc Specifies
the logical y-coordinate of the upper-left corner of the source bitmap. dwRop Specifies
the raster operation to be performed. Raster-operation codes define how the
GDI combines colors in output operations that involve a current brush, a
possible source bitmap, and a destination bitmap. The following lists
raster-operation codes for dwRop and their descriptions:
For
a complete list of raster-operation codes, see About Raster Operation Codes in the
Appendices section of the Win32 SDK Programmer¡¯s Reference. Remarks Copies
a bitmap from the source device context to this current device context. The
application can align the windows or client areas on byte boundaries to
ensure that the BitBlt
operations occur on byte-aligned rectangles. (Set the CS_BYTEALIGNWINDOW
or CS_BYTEALIGNCLIENT flags when you register the window classes.) BitBlt operations on
byte-aligned rectangles are considerably faster than BitBlt operations on
rectangles that are not byte aligned. If you want to specify class styles
such as byte-alignment for your own device context, you will have to register
a window class rather than relying on the Microsoft Foundation classes to do
it for you. Use the global function AfxRegisterWndClass. GDI
transforms nWidth and nHeight, once by using the destination
device context, and once by using the source device context. If the resulting
extents do not match, GDI uses the Windows StretchBlt function to
compress or stretch the source bitmap as necessary. If
destination, source, and pattern bitmaps do not have the same color format,
the BitBlt
function converts the source and pattern bitmaps to match the destination.
The foreground and background colors of the destination bitmap are used in
the conversion. When
the BitBlt
function converts a monochrome bitmap to color, it sets white bits (1) to the
background color and black bits (0) to the foreground color. The foreground
and background colors of the destination device context are used. To convert
color to monochrome, BitBlt
sets pixels that match the background color to white and sets all other
pixels to black. BitBlt
uses the foreground and background colors of the color device context to
convert from color to monochrome. Note
that not all device contexts support BitBlt. To check whether a given device context does
support BitBlt,
use the GetDeviceCaps member function and specify the RASTERCAPS
index. |
||||||