Gdiplus

#include <Gdiplus.h>
using namespace Gdiplus;

//声明
Gdiplus::GdiplusStartupInput m_gdiplusStartupInput;
ULONG_PTR m_gdiplusToken;
Image * m_pImage;

//构造
GdiplusStartup(&m_gdiplusToken, &m_gdiplusStartupInput, NULL);

m_pImage= NULL;
CString sPath = _T("images/vk.png");
if (FileExists(sPath))
{
WCHAR buf[MAX_PATH];
wcscpy(buf, CT2CW(sPath));
m_pImage= Image::FromFile(buf);
}

//绘制
Gdiplus::Graphics graphics(dc.GetSafeHdc());
graphics.SetInterpolationMode(InterpolationModeDefault);
graphics.DrawImage(m_pImage, 0, 0, m_rClient.Width(), m_rClient.Height());

 

 

//绘制文字

FontFamily fontFamily(L"微软雅黑");
Gdiplus::Font font(&fontFamily,16,FontStyleRegular,UnitPixel);
StringFormat strformat;
strformat.SetAlignment(StringAlignment::StringAlignmentCenter);
strformat.SetLineAlignment(StringAlignment::StringAlignmentCenter);
RectF strRc;
strRc.X = 106;
strRc.Y = 27;
strRc.Width = 200;
strRc.Height = 25;
SolidBrush strBrush(Color(255,255,255,255));
graphics.DrawString(CT2CW(m_sTitle), (INT)wcslen(CT2CW(m_sTitle)), &font, strRc, &strformat, &strBrush);

Gdiplus::Pen penLine(Color(255, 0, 153, 255));
graphics.DrawEllipse(&penLine, 431, 258, 170, 170);

 

 

//销毁
if (m_pImage)
{
try
{
delete m_pImage;
}
catch (...)
{

}
m_pImage = NULL;
}
GdiplusShutdown(m_gdiplusToken);

原文地址:https://www.cnblogs.com/waterair/p/6739257.html