Commit 739d4f95 authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander Trofimov

Реализованы некоторые функции рендерера : выставление настроек пена, браша,...

Реализованы некоторые функции рендерера : выставление настроек пена, браша, шрифта. Реализована отрисовка картинок.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63132 954022d7-b5bf-4e40-9824-e11837661b57
parent 40b82b45
This diff is collapsed.
This diff is collapsed.
......@@ -3,6 +3,8 @@
#include "stdafx.h"
#include "../PdfRenderer.h"
#include "../Src/Streams.h"
#include "../Src/Utils.h"
#include "../Src/Objects.h"
......@@ -30,6 +32,11 @@
#include "../../DesktopEditor/cximage/tiff/tiffio.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
#include "../../DesktopEditor/raster/Metafile/MetaFile.h"
#include <vector>
#ifdef DrawText
#undef DrawText
#endif
......@@ -821,19 +828,92 @@ void TestDocument9()
oPdf.Close();
}
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 ConvertFolder(MetaFile::CMetaFile &oMetaFile, std::wstring wsFolderPath, const int nType)
{
CPdfRenderer oRenderer;
oMetaFile.Close();
std::wstring sExt;
switch (nType)
{
case MetaFile::c_lMetaEmf: sExt = L"emf"; break;
case MetaFile::c_lMetaWmf: sExt = L"wmf"; break;
case MetaFile::c_lMetaSvm: sExt = L"svm"; break;
}
std::vector<std::wstring> vFiles = GetAllFilesInFolder(wsFolderPath, sExt);
for (int nIndex = 0; nIndex < vFiles.size(); nIndex++)
{
oRenderer.NewPage();
std::wstring wsFilePath = wsFolderPath;
wsFilePath.append(vFiles.at(nIndex));
if (oMetaFile.LoadFromFile(wsFilePath.c_str()))
{
double dW = 210;
double dH = 297;
//double dW, dH, dX, dY;
//oMetaFile.GetBounds(&dX, &dY, &dW, &dH);
oRenderer.put_Width(dW);
oRenderer.put_Height(dH);
oMetaFile.DrawOnRenderer(&oRenderer, 0, 0, dW, dH);
oMetaFile.Close();
}
printf("%d of %d %S\n", nIndex, vFiles.size(), vFiles.at(nIndex).c_str());
}
oRenderer.SaveToFile(wsFolderPath + L"Out.pdf");
}
void TestMetafile()
{
CApplicationFonts oFonts;
oFonts.Initialize();
MetaFile::CMetaFile oMetaFile(&oFonts);
ConvertFolder(oMetaFile, L"D://Test Files//Emf//", MetaFile::c_lMetaEmf);
}
void main()
{
TestStreams();
TestObjects();
TestEncrypt();
TestDict();
TestDocument1();
TestDocument2();
TestDocument3();
TestDocument4();
TestDocument5();
TestDocument6();
TestDocument7();
TestDocument8();
TestDocument9();
//TestStreams();
//TestObjects();
//TestEncrypt();
//TestDict();
//TestDocument1();
//TestDocument2();
//TestDocument3();
//TestDocument4();
//TestDocument5();
//TestDocument6();
//TestDocument7();
//TestDocument8();
//TestDocument9();
TestMetafile();
}
......@@ -99,7 +99,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\..\..\DesktopEditor\freetype-2.5.2\include;..\..\..\DesktopEditor\agg-2.4\include;..\..\..\DesktopEditor\cximage\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\DesktopEditor\freetype-2.5.2\include;..\..\DesktopEditor\agg-2.4\include;..\..\DesktopEditor\cximage\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4018;4005;4267</DisableSpecificWarnings>
</ClCompile>
<Link>
......
......@@ -47,6 +47,22 @@ namespace PdfWriter
Add("BitsPerComponent", 8);
SetFilter(STREAM_FILTER_JPX_DECODE);
}
void CImageDict::LoadJpx(BYTE* pBuffer, int nBufferSize, unsigned int unWidth, unsigned int unHeight)
{
CMemoryStream* pStream = new CMemoryStream();
if (!pStream)
return;
pStream->Write(pBuffer, nBufferSize);
SetStream(m_pXref, pStream);
Add("Type", "XObject");
Add("Subtype", "Image");
Add("Height", unHeight);
Add("Width", unWidth);
Add("ColorSpace", "DeviceRGB");
Add("BitsPerComponent", 8);
SetFilter(STREAM_FILTER_JPX_DECODE);
}
void CImageDict::LoadJb2(const wchar_t* wsFilePath, unsigned int unWidth, unsigned int unHeight)
{
CFileStream* pStream = new CFileStream();
......@@ -108,16 +124,28 @@ namespace PdfWriter
Add("Height", unHeight);
Add("BitsPerComponent", 8);
}
void CImageDict::LoadSMask(const BYTE* pBgra, unsigned int unWidth, unsigned int unHeight)
void CImageDict::LoadSMask(const BYTE* pBgra, unsigned int unWidth, unsigned int unHeight, unsigned char unAlpha)
{
CMemoryStream* pStream = new CMemoryStream();
CMemoryStream* pStream = new CMemoryStream(unWidth * unHeight);
if (!pStream)
return;
if (255 != unAlpha)
{
double dKoef = unAlpha / 255.0;
for (unsigned int unIndex = 0, unSize = 4 * unWidth * unHeight; unIndex < unSize; unIndex += 4)
{
BYTE nChar = *(pBgra + unIndex + 3) * dKoef;
pStream->Write(&nChar, 1);
}
}
else
{
for (unsigned int unIndex = 0, unSize = 4 * unWidth * unHeight; unIndex < unSize; unIndex += 4)
{
pStream->Write(pBgra + unIndex + 3, 1);
}
}
CImageDict* pImageSMask = new CImageDict(m_pXref, m_pDocument);
if (!pImageSMask)
......
......@@ -28,10 +28,11 @@ namespace PdfWriter
void LoadJpeg(const wchar_t* wsTempFile, unsigned int unWidth, unsigned int unHeight);
void LoadJpx(const wchar_t* wsTempFile, unsigned int unWidth, unsigned int unHeight);
void LoadJpx(BYTE* pBuffer, int nBufferSize, unsigned int unWidth, unsigned int unHeight);
void LoadJb2(const wchar_t* wsTempFile, unsigned int unWidth, unsigned int unHeight);
void LoadCCITT4(const wchar_t* wsTempFile, unsigned int unWidth, unsigned int unHeight);
void LoadRaw(const BYTE* pBgra, unsigned int unWidth, unsigned int unHeight);
void LoadSMask(const BYTE* pBgra, unsigned int unWidth, unsigned int unHeight);
void LoadSMask(const BYTE* pBgra, unsigned int unWidth, unsigned int unHeight, unsigned char lAlpha = 255);
void LoadBW(const BYTE* pImage, unsigned int unWidth, unsigned int unHeight, unsigned int unStride);
void LoadBW(Pix* pPix, unsigned int unWidth, unsigned int unHeight);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment