1. 선언 부분
#include <windows.h>
#include <gdiplus.h>

using namespace Gdiplus;
#pragma comment(lib, "gdiplus")

GDI +  사용함을 뜻함

2. WinMain 함수 선언 부분에서
// GDI Plus 초기화
 ULONG_PTR gpToken;
 GdiplusStartupInput gpsi;
 if (GdiplusStartup(&gpToken,&gpsi,NULL) != Ok)
 {
      MessageBox(NULL,L"GDI+ 라이브러리를 초기화할 수 없습니다.",L"알림",MB_OK);
      return 0;
 }

3. 사용은 WinProc 함수의 WM_PAINT 부분에서
case WM_PAINT:
      hdc=BeginPaint(hWnd, &ps);
      Game_Proc.OnPaint(hdc);
      EndPaint(hWnd, &ps);
return 0;

4. OnPaint(hdc) 함수로 모든 이미지 처리
class Game : private Image
{
private:
 // 게임에 사용할 이미지 선언 부분
     Image *m_iStage_me;              // 배경
     Image *m_iStage_you;
     Image *m_iChess_Command;   // 스프라이트
     ImageAttributes attr;                // 스프라이트 투명화 지정을 위해 필요

public:
 // 게임 초기화 (이미지 로딩부분...)
 Game()
 {
      m_iStage_me   = Image::FromFile(L"Image\\mystage.bmp");
      m_iStage_you  = Image::FromFile(L"Image\\yourstage.bmp");
      m_iChess_Command = Image::FromFile(L"Image\\Command.bmp");

      Color Trans_Color(0,255,255,255);      // 투명색 지정하되 흰색이 투명색
      attr.SetColorKey(Trans_Color,Trans_Color);
 }
 
 // 게임 그래픽 뿌려주는 영역..
 void OnPaint(HDC hdc)
 {
  Graphics G(hdc);
  // 실제 이미지가 뿌려지는 영역
  {
       G.DrawImage(m_iStage_me,0,0,m_iStage_me->GetWidth(),
                                                  m_iStage_me->GetHeight());
   
       G.DrawImage(m_iStage_you,0,256,m_iStage_you->GetWidth(),
                                                  m_iStage_you->GetHeight());

       G.DrawImage(m_iChess_Command,
   Rect(0,0, m_iChess_Command->GetWidth(), m_iChess_Command->GetHeight()),
                0, 0, m_iChess_Command->GetWidth(), m_iChess_Command->GetHeight(),
                UnitPixel, &this->attr);   // 투명색 지정하면서 그린다
  }

  // NDS상 가려지는 영역
  {
   SolidBrush S(Color(255,255,0));
   G.FillRectangle(&S,0,193,256,62);
   G.FillRectangle(&S,0,448,256,64);
   
   Font Font(L"굴림체",20,FontStyleRegular,UnitPixel);
   SolidBrush Brush_Font(Color(0,0,255));
   G.DrawString(L"Main 화면 밖 영역",-1,&Font,PointF(40,212),&Brush_Font);
   G.DrawString(L"Sub 화면 밖 영역",-1,&Font,PointF(40,468),&Brush_Font);
  }
 }
};

+ Recent posts