본문 바로가기

GDI & GDI+

VC++에서 GDI+ 사용 방법

728x90
반응형
VC++에서 GDI+ 사용방법

1. 프로젝트의 stdafx.h 파일에 다음 두 줄의 코드를 삽입한다.
#include <gdiplus.h>
using namespace Gdiplus;

2. 어플리케이션 클래스에 다음 멤버를 추가한다.
private:
    ULONG_PTR m_gdiplusToken;

3. 어플리케이션 클래스의 InitInstance 함수에 다음 GDI+ 초기화 코드를 추가한다. 코드 위치는 함수 시작 부분이 좋겠다.
    // Initialize GDI+
    Gdiplus::GdiplusStartupInput gdiplusStartupInput;
    Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);   

4. 어플리케이션 클래스에 ExitInstance 함수를 오버라이드하여 다음 코드를 추가한다.
    Gdiplus::GdiplusShutdown(m_gdiplusToken);

5. 프로젝트 속성중 링커 - 입력 - 추가 종속성 항목에 다음을 입력한다.
gdiplus.lib
사용자 삽입 이미지

Remarks

You must call GdiplusStartup before you create any GDI+ objects, and you must delete all of your GDI+ objects (or have them go out of scope) before you call GdiplusShutdown.

You can call GdiplusStartup on one thread and call GdiplusShutdown on another thread as long as you delete all of your GDI+ objects (or have them go out of scope) before you call GdiplusShutdown.

Do not call GdiplusStartup or GdiplusShutdown in DllMain or in any function that is called by DllMain. If you want to create a DLL that uses GDI+, you should use one of the following techniques to initialize GDI+:

  • Require your clients to call GdiplusStartup before they call the functions in your DLL and to call GdiplusShutdown when they have finished using your DLL.
  • Export your own startup function that calls GdiplusStartup and your own shutdown function that calls GdiplusShutdown. Require your clients to call your startup function before they call other functions in your DLL and to call your shutdown function when they have finished using your DLL.
  • Call GdiplusStartup and GdiplusShutdown in each of your functions that make GDI+ calls.

반응형

'GDI & GDI+' 카테고리의 다른 글

[C#] 이미지 출력 (확대/축소)  (0) 2008.12.03
텍스트 Outline 효과  (0) 2008.09.05