VS2013中使用GDI+绘图

VC范例,400多个例子源代码下载

http://download.csdn.net/detail/bigtree_mfc/7727977

VS2013中使用GDI+绘图和VC6.0不同,在VC6.0中能绘出的图像在VS2013中不会显示,原因就是在VS2013中需要添加初始化GDI+;

绘图

对话框视图类中:(绘图部分大同小异,)

void **View::OnDraw(CDC *pDC)
{

//初始化部分

GdiplusStartupInput gdiplusStartupInput;

ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);


HDC hdc = pDC->m_hDC;
using namespace Gdiplus;
Graphics graphics(hdc);
graphics.SetSmoothingMode(SmoothingModeAntiAlias);
Pen newPen(Color(0, 255, 255), 2);

graphics.DrawLine(&newPen, 0, 0, 500, 500);
}

注:顶部添加GDI+定义注意要4行全部添加

#pragma once
#include <GdiPlus.h>
#pragma comment(lib, "GdiPlus.lib")
using namespace Gdiplus;

效果:

 
 

http://blog.csdn.net/bigtree_mfc/article/details/46858127

原文地址:https://www.cnblogs.com/findumars/p/5801430.html