加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Metafile::EmfToWmfBits的使用

发布时间:2020-12-14 05:07:32 所属栏目:大数据 来源:网络整理
导读:其中涉及到string转换LPCWSTR以及模块绝对路径的调用 #include iostream #include stdio.h #include WINDOWS.H #include shellapi.h #include gdiplus.h #include Shlwapi.h #include string #pragma comment (lib,"Shlwapi.lib") #pragma comment(lib,"gdip

其中涉及到string转换LPCWSTR以及模块绝对路径的调用

#include <iostream>
#include <stdio.h>
#include <WINDOWS.H>
#include <shellapi.h>
#include <gdiplus.h>
#include <Shlwapi.h>
#include <string>

#pragma comment (lib,"Shlwapi.lib")
#pragma comment(lib,"gdiplus.lib")
#pragma comment(lib,"shell32.lib")

using namespace Gdiplus;
using std::string;

LPWSTR ConvertToLPWSTR(const std::string& s)
{
    LPWSTR ws = new wchar_t[s.size() + 1]; // +1 for zero at the end
    copy(s.begin(),s.end(),ws);
    ws[s.size()] = 0; // zero at the end
    return ws;
}

int main(int argc,char **argv)
{
    UINT size1 = 0;
    WCHAR path[MAX_PATH];
    string name;

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

    std::cout << "Please input a file name" << std::endl;
    std::cin >> name;
    LPCWSTR name_ = LPCWSTR(ConvertToLPWSTR(name));

    GetModuleFileNameW(NULL,path,MAX_PATH);
    PathRemoveFileSpecW(path);
    PathAppendW(path,name_);


    Metafile myMetafile(path);
    Status S_ch = myMetafile.GetLastStatus();
    
    HENHMETAFILE hEmf = myMetafile.GetHENHMETAFILE();
    size1 = Metafile::EmfToWmfBits(
        hEmf,0,NULL,MM_ANISOTROPIC,EmfToWmfBitsFlagsEmbedEmf);
    std::cout << size1 << std::endl;

}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读