2008/03/06
다이얼로그 위에 투명 이미지 그리기
이 함수를 사용함에 있어 주의해야할 점이 있다. 소스 이미지의 크기를 넘겨주는 nWidthSrc, nHeightSrc 는 소스이미지의 크기와 같거나 작아야 하며 그렇지 않을 경우에는 출력되지 않는다.
Source
2009/03/26 추가
위의 코드 중 잘못된 부분이 있어 수정 함.
CBitmap 에서 Bitmap 리소스를 불러들일때 LoadBitmap 함수를 사용해야 하며
메모리 DC에 bitmap 을 할당할때 BITMAP 을 할당하면 안되고 CBitmap 을 할당 해야 함.
Original Post : http://neodreamer-dev.tistory.com/78
BOOL TransparentBlt(
HDC hdcDest,
int nXOriginDest,
int nYOriginDest,
int nWidthDest,
int hHeightDest,
HDC hdcSrc,
int nXOriginSrc,
int nYOriginSrc,
int nWidthSrc,
int nHeightSrc,
UINT crTransparent
);
MSDN 함수 설명 보기
Parameters
hdcDest
[in] Handle to the destination device context.
nXOriginDest
[in] Specifies the x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
nYOriginDest
[in] Specifies the y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
nWidthDest
[in] Specifies the width, in logical units, of the destination rectangle.
hHeightDest
[in] Handle to the height, in logical units, of the destination rectangle.
hdcSrc
[in] Handle to the source device context or a source bitmap handle.
nXOriginSrc
[in] Specifies the x-coordinate, in logical units, of the source rectangle.
nYOriginSrc
[in] Specifies the y-coordinate, in logical units, of the source rectangle.
nWidthSrc
[in] Specifies the width, in logical units, of the source rectangle.
nHeightSrc
[in] Specifies the height, in logical units, of the source rectangle.
crTransparent
[in] Indicates that the RGB color in the source bitmap to treat as transparent.
Return Values
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE.
To get extended error information, call GetLastError.
hdcDest
[in] Handle to the destination device context.
nXOriginDest
[in] Specifies the x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
nYOriginDest
[in] Specifies the y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
nWidthDest
[in] Specifies the width, in logical units, of the destination rectangle.
hHeightDest
[in] Handle to the height, in logical units, of the destination rectangle.
hdcSrc
[in] Handle to the source device context or a source bitmap handle.
nXOriginSrc
[in] Specifies the x-coordinate, in logical units, of the source rectangle.
nYOriginSrc
[in] Specifies the y-coordinate, in logical units, of the source rectangle.
nWidthSrc
[in] Specifies the width, in logical units, of the source rectangle.
nHeightSrc
[in] Specifies the height, in logical units, of the source rectangle.
crTransparent
[in] Indicates that the RGB color in the source bitmap to treat as transparent.
Return Values
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE.
To get extended error information, call GetLastError.
Source
void CMyDialog::OnPaint()
{
CPaintDC dc(this); // device context for painting
CDC MemDC;
MemDC.CreateCompatibleDC( &dc );
CBitmap Bmp;
BITMAP bmp;
//Bmp.LoadImage( IDB_BATMAP1 );
Bmp.LoadBitmap( IDB_BATMAP1 ); // 2009/03/26
Bmp.GetBitmap( &bmp );
//MemDC.SelectObject( &bmp );
MemDC.SelectObject( &Bmp ); // 2009/03/26
dc.TransparentBlt( 0, 0, bmp.bmWidth, bmp.bmHeight,
&MemDC, 0, 0, bmp.bmWidth, bmp.bmHeight, RGB(255, 255, 255));
MemDC.DeleteDC();
}
2009/03/26 추가
위의 코드 중 잘못된 부분이 있어 수정 함.
CBitmap 에서 Bitmap 리소스를 불러들일때 LoadBitmap 함수를 사용해야 하며
메모리 DC에 bitmap 을 할당할때 BITMAP 을 할당하면 안되고 CBitmap 을 할당 해야 함.
Original Post : http://neodreamer-dev.tistory.com/78
Labels:
TistoryOldPost
,
TransparentBlt
,
Visual C++
,
이미지 투명처리
,
투명이미지
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment