본문 바로가기
C/C++/API

API TransparentBlt()함수

by 꿀꿀이냐옹이 2009. 8. 5.
반응형

필요한 lib파일.

Msimg32.lib

#pragma comment(lib,"Msimg32")
 

 

TransparentBlt 함수는


BOOL TransparentBlt(
  HDC
hdcDest,        // handle to destination DC
  int nXOriginDest,   // x-coord of destination upper-left corner
  int nYOriginDest,   // y-coord of destination upper-left corner
  int nWidthDest,     // width of destination rectangle
  int hHeightDest,    // height of destination rectangle
  HDC hdcSrc,         // handle to source DC
  int nXOriginSrc,    // x-coord of source upper-left corner
  int nYOriginSrc,    // y-coord of source upper-left corner
  int nWidthSrc,      // width of source rectangle                        <=    1
  int
nHeightSrc,     // height of source rectangle                       <=    2
  UINT crTransparent  // color to make transparent
);

 

  1 (소스의 가로)   과   2 (소스의 세로) 는 소스의 원래 값보다 작아야 한다 .

즉, 1 과 2는 소스 DC가 소스비트맵을  선택하고 있을경우 소스 비트맵의 가로와

세로길이보다 커서는 안된다 . (크면 출력 안됨) 

  그런데  StretchBlt 함수의  1과 2는 소스 비트맵의 가로와 세로길이보다

 커도 출력잘된다. 

 

TransparentBlt() 사용예

 

 HDC hdc;
 PAINTSTRUCT ps;
 HDC MemDC;
 HBITMAP MyBitmap, OldBitmap;
 BITMAP bit;
 int bx,by;//이미지 사이즈를 잡기위한 변수

 

  hdc=BeginPaint(hWnd,&ps);
  MemDC=CreateCompatibleDC(hdc);
  MyBitmap=LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_BITCHAR));
  OldBitmap=(HBITMAP)SelectObject(MemDC, MyBitmap);

  GetObject(MyBitmap, sizeof(BITMAP),&bit);
  bx=bit.bmWidth;
  by=bit.bmHeight;
  TransparentBlt(hdc,0,0,bx,by,MemDC,0,0,bx,by,RGB(255,0,255));
  SelectObject(MemDC,OldBitmap);
  DeleteObject(MyBitmap);
  DeleteDC(MemDC);
  EndPaint(hWnd,&ps);

 

색상이 255,0,255일 경우 투명처리함

 

반응형

'C/C++ > API' 카테고리의 다른 글

2009.07.27 API TIMER  (0) 2009.07.27
2007.07.27 API Mouse입력  (0) 2009.07.27
2009.07.27 API KEY입력  (0) 2009.07.27
2009.07.27 API도형그리기  (0) 2009.07.27
API기본 함수  (0) 2009.07.27

댓글