zoukankan      html  css  js  c++  java
  • 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);

  • 相关阅读:
    linux awk命令详解
    Linux 大页面使用与实现简介(转)
    二层设备与三层设备的区别--总结
    Windows下的cd命令
    linux常用命令
    上班第一天
    linux 内核移植和根文件系统的制作
    Sizeof与Strlen的区别与联系
    嵌入式软件工程师面试题
    SpringBoot简单打包部署(附工程)
  • 原文地址:https://www.cnblogs.com/waterair/p/6739257.html
Copyright © 2011-2022 走看看