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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM