如何在 VC.NET 中利用 GDI+ 进行开发?

GDI+ is a class-based application programming interface (API) for C/C++ programmers.

利用 GDI+ 进行开发分为四个步骤:

1. 确保 VC.NET 已正确安装,然后在项目源程序中加上正确的头文件和链接库:

#include

 1<gdiplus.h>   
 2#pragma comment(lib, "gdiplus.lib")   
 3using namespace Gdiplus;   
 4  
 52\. 初始化GDI+库(在能够正确地引用 GDI+ 类之前必须进行初始化):   
 6  
 7GdiplusStartupInput gdiplusStartupInput;   
 8ULONG_PTR gdiplusToken;   
 9GdiplusStartup(&amp;gdiplusToken, &amp;gdiplusStartupInput, NULL);   
10  
11  
123\. 用 GDI+ 进行图形绘制,例如,在某一窗口类的 OnPaint() 消息函数中:   
13  
14Graphics graphics(dc); //dc 为 HDC 类型的图形设备上下文句柄   
15Bitmap bitmap(L"c:\\\abc.bmp");   
16graphics.DrawImage(&amp;bitmap, 0,0, 100,100);   
17Pen pen(Color(105,255,0,0));   
18graphics.DrawLine(&amp;pen, 0,0,100,100);   
19  
204\. 程序结束前:   
21  
22GdiplusShutdown(gdiplusToken);   
23  
24参阅:MSDN Platform SDK GDI+</gdiplus.h>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus