Files
core/DesktopEditor/raster/Metafile/TestMain.cpp
Ilya.Kirillov e7d4221731 Исправлен баг с чтением команды EMR_EXTTEXTOUTW.
git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@65043 954022d7-b5bf-4e40-9824-e11837661b57
2016-05-21 00:34:16 +03:00

87 lines
2.3 KiB
C++

//#define _CRTDBG_LEAK_CHECK_DF
#include "stdafx.h"
#include <vector>
#include "../../fontengine/ApplicationFonts.h"
#include "MetaFile.h"
using namespace MetaFile;
std::vector<std::wstring> GetAllFilesInFolder(std::wstring wsFolder, std::wstring wsExt)
{
std::vector<std::wstring> vwsNames;
std::wstring wsSearchPath = wsFolder;
wsSearchPath.append(L"*.");
wsSearchPath.append(wsExt);
WIN32_FIND_DATA oFindData;
HANDLE hFind = ::FindFirstFile(wsSearchPath.c_str(), &oFindData);
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
if (!(oFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
vwsNames.push_back(oFindData.cFileName);
}
} while (::FindNextFile(hFind, &oFindData));
::FindClose(hFind);
}
return vwsNames;
}
void ConvertFile(CMetaFile &oMetaFile, std::wstring wsFilePath)
{
oMetaFile.Close();
std::wstring wsDstFilePath = (wsFilePath.substr(0, wsFilePath.size() - 3)).append(L"png");
if (oMetaFile.LoadFromFile(wsFilePath.c_str()))
{
oMetaFile.ConvertToRaster(wsDstFilePath.c_str(), 4, 1000);
}
}
void ConvertFolder(CMetaFile &oMetaFile, std::wstring wsFolderPath, const int nType)
{
oMetaFile.Close();
std::wstring sExt;
switch(nType)
{
case c_lMetaEmf: sExt = L"emf"; break;
case c_lMetaWmf: sExt = L"wmf"; break;
case c_lMetaSvm: sExt = L"svm"; break;
}
std::vector<std::wstring> vFiles = GetAllFilesInFolder(wsFolderPath, sExt);
for (int nIndex = 0; nIndex < vFiles.size(); nIndex++)
{
std::wstring wsFilePath = wsFolderPath;
wsFilePath.append(vFiles.at(nIndex));
if (oMetaFile.LoadFromFile(wsFilePath.c_str()))
{
std::wstring wsDstFilePath = (wsFilePath.substr(0, wsFilePath.size() - 3)).append(L"png");
double w, h, x, y;
oMetaFile.GetBounds(&x, &y, &w, &h);
oMetaFile.ConvertToRaster(wsDstFilePath.c_str(), 4, 500);
oMetaFile.Close();
}
printf("%d of %d %S\n", nIndex, vFiles.size(), vFiles.at(nIndex).c_str());
}
}
void main()
{
CApplicationFonts oFonts;
oFonts.Initialize();
CMetaFile oMetaFile(&oFonts);
//ConvertFolder(oMetaFile, L"D://Test Files//Wmf//Test//", c_lMetaWmf);
ConvertFolder(oMetaFile, L"D://Test Files//Emf//Temp//", c_lMetaEmf);
//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
//_CrtDumpMemoryLeaks();
}