TODAY : / TOTAL :

120627_API :: TextRot , FONT, BITMAP

  • Share this:
반응형
TextRot
 SetBkMode(hdc,TRANSPARENT); // 음영처리 함수(기본:불투명)
                                              // TRANSPARENT = 투명.


FONT
 
hFont=CreateFont(50,                // 폰트 크기
0,                                           // 장평
0,                                           // 문자열 각도 (3시방향 기준 0도, 360도 사용)
0,                                           // 문자 각도 (한 글자의 각도 지정
0,                                           // 두께 (0~1000)
0,                                           // 기울임
0,                                           // 밑줄 
0,                                           // 관통선
HANGEUL_CHARSET,          // Charset 지정
0,                                          // 출력 정확도
0,                                          // 클리핑 정확도
0,                                          // 논리적폰트와 물리적 폰트의 근접 지정
VARIABLE_PITCH | FF_ROMAN,  // 폰트의 피치와 그룹 설정.
TEXT("궁서")
);                     // 글꼴이름을 나타내는 문자열 지정.


Bitmap

 LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
 HDC hdc,MemDC;
 PAINTSTRUCT ps;
 HBITMAP MyBitmap, OldBitmap;
 switch (iMessage) {
 case WM_PAINT:
  hdc = BeginPaint(hWnd, &ps);
  MemDC=CreateCompatibleDC(hdc);  // 메모리DC (sprintf 실행 방식과 비슷하다고 보면 됨)
  MyBitmap=LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_BITMAP1));  // 비트맵 리소스 저장.
//MyBitmap=LoadBitmap(인스턴스 핸들, 리소스선택);
  
  OldBitmap=(HBITMAP)SelectObject(MemDC, MyBitmap);      
// 비트맵 역시 마찬가지로, 기본 오브젝트를 따로 저장해둔다음, 사용 후...
  
// 비트맵 복사 함수. (그대로 복사)
  BitBlt(hdc, 0,0,123,160,MemDC,0,0,SRCCOPY);
  // MemDC 에 있는 비트맵을 hdc 화면에 SRCCOPY (복사) 하겠다.
/*  
BitBlt(hdc,  //DC 핸들
   0,             // x좌표
   0,             // y좌표
   123,          // 비트맵의 가로 크기
   160,          // 비트맵의 세로 크기
   MemDC,   //  비트맵이 저장된 DC
   0,             // MemDC 에서 복사 시작점. x 좌표
   0,             // MemDC 에서 복사 시작점. y 좌표
   SRCCOPY); // 연산 방법 (복사)
*/



// 비트맵 복사 함수( 확대 축소 가능)
 //StretchBlt(hdc,0,0,246,320,MemDC,0,0,123,160,SRCCOPY);   
/*
StretchBlt(hdc, // DC 핸들
 0,                  // x 좌표
 0,                  // y 좌표
 246,               // 출력할 가로 크기
 320,               // 출력할 세로 크기
 MemDC,        // MemDC - 비트맵이 저장된 DC
 0,                  // MemDC 에서 복사 시작점. x 좌표
 0,                  // MemDC 에서 복사 시작점. y 좌표
 123,               // 비트맵의 가로 크기
 160,               // 비트맵의 세로 크기
 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));
}




Draw BITMAP

 // 비트맵 출력을 자주하게되면, 함수로 구현해두고 계속 호출해서 쓰면 됨.
void DrawBitmap(HDC hdc,int x,int y,HBITMAP hBit)
{
 HDC MemDC;
 HBITMAP OldBitmap;
 int bx,by;
 BITMAP bit;

 MemDC=CreateCompatibleDC(hdc);
 OldBitmap=(HBITMAP)SelectObject(MemDC, hBit);

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

 BitBlt(hdc,x,y,bx,by,MemDC,0,0,SRCCOPY);

 SelectObject(MemDC,OldBitmap);
 DeleteDC(MemDC);
}

LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
 HDC hdc;
 PAINTSTRUCT ps;
 static HBITMAP MyBitmap;
 switch (iMessage) {
 case WM_CREATE:
  MyBitmap=LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_BITMAP1));
  return 0;
 case WM_PAINT:
  hdc = BeginPaint(hWnd, &ps);
  DrawBitmap(hdc,10,10,MyBitmap);
  DrawBitmap(hdc,320,250,MyBitmap);
  DrawBitmap(hdc,110,110,MyBitmap);
  EndPaint(hWnd, &ps);
  return 0;
 case WM_DESTROY:
  DeleteObject(MyBitmap);
  PostQuitMessage(0);
  return 0;
 }
 return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}






반응형

SEARCH

태그로 찾아보기