Win32中GDI+应用(二)--初始化与清理

时间:2023-03-09 13:38:23
Win32中GDI+应用(二)--初始化与清理

GDI+提供了GdiplusStartup和 GdiplusShutdown 函数来进行初始化和完成清理工作。你必须在调用其他的GDI+函数之前,调用GdiplusStartup函数,在完成GDI+工作后调用GdiplusShutdown 。
具体的可以看下面的MSDN上的例子:

#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;
int main()
{
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
Image* image = new Image(L"FakePhoto.jpg");
printf("The width of the image is %u.\n", image->GetWidth());
printf("The height of the image is %u.\n", image->GetHeight());
delete image;
GdiplusShutdown(gdiplusToken);
return 0;
}

具体的使用方法,可以参考MSDN的说明。

转载地址:http://www.cppblog.com/dingding/archive/2008/06/27/54792.html