Commit 16b3747a authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander Trofimov

Новый вариант Wmf.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62280 954022d7-b5bf-4e40-9824-e11837661b57
parent 542eb847
......@@ -3036,6 +3036,7 @@ DesktopEditor/mac_build/raster/raster.xcodeproj/xcuserdata svnc_tsvn_003alogmins
DesktopEditor/mac_build/raster/raster.xcodeproj/xcuserdata/alexey.musinov.xcuserdatad svnc_tsvn_003alogminsize=5
DesktopEditor/mac_build/raster/raster.xcodeproj/xcuserdata/alexey.musinov.xcuserdatad/xcschemes svnc_tsvn_003alogminsize=5
DesktopEditor/raster/Metafile svnc_tsvn_003alogminsize=5 svn_global_002dignores
DesktopEditor/raster/Metafile/Common svnc_tsvn_003alogminsize=5
DesktopEditor/raster/Metafile/Emf svnc_tsvn_003alogminsize=5
DesktopEditor/raster/Metafile/Wmf svnc_tsvn_003alogminsize=5
DoctRenderer/COMMON/Dlls/AVSGraphics.dll svn_mime_002dtype=application%2Foctet-stream
......
......@@ -15,6 +15,7 @@ typedef unsigned char BYTE;
#include "Wmf/WmfTypes.h"
#include "Wmf/WmfUtils.h"
#include "Emf/EmfObjects.h"
#include "Wmf/WmfObjects.h"
namespace MetaFile
{
......@@ -596,6 +597,181 @@ namespace MetaFile
*this >> oBitmap.cxSrc;
*this >> oBitmap.cySrc;
return *this;
}
CDataStream& operator>>(TWmfRect& oRect)
{
*this >> oRect.Left;
*this >> oRect.Top;
*this >> oRect.Right;
*this >> oRect.Bottom;
return *this;
}
CDataStream& operator>>(TWmfColor& oColor)
{
*this >> oColor.r;
*this >> oColor.g;
*this >> oColor.b;
*this >> oColor.a;
return *this;
}
CDataStream& operator>>(TWmfPointS& oPoint)
{
*this >> oPoint.x;
*this >> oPoint.y;
return *this;
}
CDataStream& operator>>(TWmfLogBrush& oBrush)
{
*this >> oBrush.BrushStyle;
*this >> oBrush.Color;
*this >> oBrush.BurshHatch;
return *this;
}
CDataStream& operator>>(CWmfFont* pFont)
{
*this >> pFont->Height;
*this >> pFont->Width;
*this >> pFont->Escapement;
*this >> pFont->Orientation;
*this >> pFont->Weight;
*this >> pFont->Italic;
*this >> pFont->Underline;
*this >> pFont->StrikeOut;
*this >> pFont->CharSet;
*this >> pFont->OutPrecision;
*this >> pFont->ClipPrecision;
*this >> pFont->Quality;
*this >> pFont->PitchAndFamily;
//
unsigned char unIndex = 0;
*this >> pFont->Facename[unIndex];
while (0x00 != pFont->Facename[unIndex])
{
unIndex++;
if (32 == unIndex)
break;
*this >> pFont->Facename[unIndex];
}
return *this;
}
CDataStream& operator>>(TWmfPaletteEntry& oEntry)
{
*this >> oEntry.Values;
*this >> oEntry.Blue;
*this >> oEntry.Green;
*this >> oEntry.Red;
return *this;
}
CDataStream& operator>>(CWmfPalette* pPalette)
{
*this >> pPalette->Start;
*this >> pPalette->NumberOfEntries;
if (pPalette->NumberOfEntries > 0)
{
pPalette->aPaletteEntries = new TWmfPaletteEntry[pPalette->NumberOfEntries];
if (!pPalette->aPaletteEntries)
{
pPalette->aPaletteEntries = NULL;
pPalette->NumberOfEntries = 0;
return *this;
}
for (unsigned short ushIndex = 0; ushIndex < pPalette->NumberOfEntries; ushIndex++)
{
*this >> pPalette->aPaletteEntries[ushIndex];
}
}
else
{
pPalette->aPaletteEntries = NULL;
}
return *this;
}
CDataStream& operator>>(CWmfPen* pPen)
{
*this >> pPen->PenStyle;
*this >> pPen->Width;
*this >> pPen->Color;
return *this;
}
CDataStream& operator>>(TWmfScanLine& oLine)
{
*this >> oLine.Left;
*this >> oLine.Right;
return *this;
}
CDataStream& operator>>(TWmfScanObject& oScan)
{
*this >> oScan.Count;
*this >> oScan.Top;
*this >> oScan.Bottom;
if (oScan.Count > 0 && oScan.Count & 1) // 2
{
unsigned short ushCount = oScan.Count >> 1;
oScan.ScanLines = new TWmfScanLine[ushCount];
if (oScan.ScanLines)
{
for (unsigned short ushIndex = 0; ushIndex < ushCount; ushIndex++)
{
*this >> oScan.ScanLines[ushIndex];
}
}
else
{
oScan.ScanLines = NULL;
oScan.Count = 0;
}
}
else
{
oScan.ScanLines = NULL;
}
*this >> oScan.Count2;
return *this;
}
CDataStream& operator>>(CWmfRegion* pRegion)
{
*this >> pRegion->nextInChain;
*this >> pRegion->ObjectType;
*this >> pRegion->RegionSize;
*this >> pRegion->ScanCount;
*this >> pRegion->MaxScan;
*this >> pRegion->BoundingRectangle;
if (pRegion->ScanCount > 0)
{
pRegion->aScans = new TWmfScanObject[pRegion->ScanCount];
if (!pRegion->aScans)
{
pRegion->aScans = NULL;
pRegion->ScanCount = 0;
return *this;
}
for (unsigned short ushIndex = 0; ushIndex < pRegion->ScanCount; ushIndex++)
{
*this >> pRegion->aScans[ushIndex];
}
}
else
{
pRegion->aScans = NULL;
}
return *this;
}
......
#ifndef _METAFILE_COMMON_METAFILE_H
#define _METAFILE_COMMON_METAFILE_H
namespace MetaFile
{
class CMetaFileBase
{
public:
CMetaFileBase()
{
}
virtual ~CMetaFileBase()
{
}
virtual void SetError()
{
}
};
}
#endif //_METAFILE_COMMON_METAFILE_H
#ifndef _METAFILE_OBJECTS_H
#define _METAFILE_OBJECTS_H
namespace MetaFile
{
typedef enum
{
METAFILE_OBJECT_UNKNOWN = 0x00,
METAFILE_OBJECT_BRUSH = 0x01,
METAFILE_OBJECT_FONT = 0x02,
METAFILE_OBJECT_PEN = 0x03,
METAFILE_OBJECT_PALETTE = 0x04
} EMetaFileObjectType;
class CMetaFileObjectBase
{
public:
CMetaFileObjectBase(){}
virtual ~CMetaFileObjectBase(){}
virtual EMetaFileObjectType GetType()
{
return METAFILE_OBJECT_UNKNOWN;
}
};
}
#endif //_METAFILE_OBJECTS_H
\ No newline at end of file
#include "MetaFilePlayer.h"
namespace MetaFile
{
template<typename CMetaFileDC> CMetaFilePlayer<CMetaFileDC>::CMetaFilePlayer(CMetaFileBase* pFile) : m_pFile(pFile)
{
CMetaFileDC* pDC = new CMetaFileDC();
if (!pDC)
{
pFile->SetError();
return;
}
m_pDC = pDC;
m_vDCStack.push_back(pDC);
InitStockObjects();
};
template<typename CMetaFileDC> CMetaFilePlayer<CMetaFileDC>::~CMetaFilePlayer()
{
for (int nIndex = 0; nIndex < m_vDCStack.size(); nIndex++)
{
CMetaFileDC* pDC = m_vDCStack.at(nIndex);
delete pDC;
}
m_vDCStack.clear();
for (CMetaFileObjectMap::iterator oIterator = m_mObjects.begin(); oIterator != m_mObjects.end(); oIterator++)
{
CMetaFileObjectBase* pOldObject = oIterator->second;
delete pOldObject;
}
m_mObjects.clear();
}
template<typename CMetaFileDC> void CMetaFilePlayer<CMetaFileDC>::Clear()
{
for (int nIndex = 0; nIndex < m_vDCStack.size(); nIndex++)
{
CMetaFileDC* pDC = m_vDCStack.at(nIndex);
delete pDC;
}
m_vDCStack.clear();
for (CMetaFileObjectMap::iterator oIterator = m_mObjects.begin(); oIterator != m_mObjects.end(); oIterator++)
{
CMetaFileObjectBase* pOldObject = oIterator->second;
delete pOldObject;
}
m_mObjects.clear();
CMetaFileDC* pDC = new CMetaFileDC();
if (!pDC)
{
m_pFile->SetError();
return;
}
m_pDC = pDC;
m_vDCStack.push_back(pDC);
InitStockObjects();
}
template<typename CMetaFileDC> CMetaFileDC* CMetaFilePlayer<CMetaFileDC>::SaveDC()
{
if (!m_pDC)
{
m_pFile->SetError();
return NULL;
}
CMetaFileDC* pNewDC = m_pDC->Copy();
if (!pNewDC)
{
m_pFile->SetError();
return NULL;
}
m_vDCStack.push_back(pNewDC);
m_pDC = pNewDC;
return pNewDC;
}
template<typename CMetaFileDC> CMetaFileDC* CMetaFilePlayer<CMetaFileDC>::RestoreDC()
{
if (m_vDCStack.size() <= 1)
{
m_pFile->SetError();
return m_pDC;
}
CMetaFileDC* pDC = m_vDCStack.at(m_vDCStack.size() - 1);
m_vDCStack.pop_back();
delete pDC;
pDC = m_vDCStack.at(m_vDCStack.size() - 1);
m_pDC = pDC;
return m_pDC;
}
template<typename CMetaFileDC> CMetaFileDC* CMetaFilePlayer<CMetaFileDC>::GetDC()
{
return m_pDC;
}
template<typename CMetaFileDC> void CMetaFilePlayer<CMetaFileDC>::RegisterObject(unsigned int ulIndex, CMetaFileObjectBase* pObject)
{
CMetaFileObjectMap::const_iterator oPos = m_mObjects.find(ulIndex);
if (m_mObjects.end() != oPos)
{
CMetaFileObjectBase* pOldObject = oPos->second;
delete pOldObject;
m_mObjects.erase(ulIndex);
}
m_mObjects.insert(std::pair<unsigned int, CMetaFileObjectBase*>(ulIndex, pObject));
}
template<typename CMetaFileDC> void CMetaFilePlayer<CMetaFileDC>::SelectObject(unsigned int ulIndex)
{
CMetaFileObjectMap::const_iterator oPos = m_mObjects.find(ulIndex);
if (m_mObjects.end() != oPos)
{
CMetaFileObjectBase* pObject = oPos->second;
for (int nIndex = 0; nIndex < m_vDCStack.size(); nIndex++)
{
CMetaFileDC* pDC = m_vDCStack.at(nIndex);
switch (pObject->GetType())
{
case METAFILE_OBJECT_BRUSH: m_pDC->SetBrush(pObject); break;
case METAFILE_OBJECT_FONT : m_pDC->SetFont(pObject); break;
case METAFILE_OBJECT_PEN : m_pDC->SetPen(pObject); break;
}
}
}
}
template<typename CMetaFileDC> void CMetaFilePlayer<CMetaFileDC>::SelectPalette(unsigned int ulIndex)
{
CEmfObjectMap::const_iterator oPos = m_mObjects.find(ulIndex);
if (m_mObjects.end() != oPos)
{
CEmfObjectBase* pObject = oPos->second;
if (METAFILE_OBJECT_PALETTE == pObject->GetType())
m_pDC->SetPalette(pObject);
}
}
template<typename CMetaFileDC> void CMetaFilePlayer<CMetaFileDC>::DeleteObject(unsigned int ulIndex)
{
// TODO: DC_BRUSH DC_PEN
CEmfObjectMap::const_iterator oPos = m_mObjects.find(ulIndex);
if (m_mObjects.end() != oPos)
{
CEmfObjectBase* pObject = oPos->second;
switch (pObject->GetType())
{
case METAFILE_OBJECT_BRUSH: m_pDC->RemoveBrush(pObject); break;
case METAFILE_OBJECT_FONT: m_pDC->RemoveFont(pObject); break;
case METAFILE_OBJECT_PEN: m_pDC->RemovePen(pObject); break;
}
delete pObject;
m_mObjects.erase(ulIndex);
}
}
template<typename CMetaFileDC> void CMetaFilePlayer<CMetaFileDC>::InitStockObjects()
{
}
}
\ No newline at end of file
#ifndef _METAFILE_COMMON_H
#define _METAFILE_COMMON_H
#include <map>
#include <vector>
#include "MetaFileObjects.h"
#include "MetaFile.h"
namespace MetaFile
{
template <typename CMetaFileDC> class CMetaFilePlayer
{
public:
CMetaFilePlayer(CMetaFileBase* pFile);
~CMetaFilePlayer();
void Clear();
CMetaFileDC* SaveDC();
CMetaFileDC* RestoreDC();
CMetaFileDC* GetDC();
void RegisterObject(unsigned int ulIndex, CMetaFileObjectBase* pObject);
void SelectObject(unsigned int ulIndex);
void DeleteObject(unsigned int ulIndex);
void SelectPalette(unsigned int ulIndex);
private:
virtual void InitStockObjects();
private:
typedef std::map<unsigned int, CMetaFileObjectBase*> CMetaFileObjectMap;
CMetaFileDC* m_pDC;
std::vector<CMetaFileDC*> m_vDCStack;
CMetaFileBase* m_pFile;
CMetaFileObjectMap m_mObjects;
};
}
#endif //_METAFILE_COMMON_H
\ No newline at end of file
......@@ -13,10 +13,11 @@
#include "../../../fontengine/FontManager.h"
#include <iostream>
#include "../Common/MetaFile.h"
namespace MetaFile
{
class CEmfFile
class CEmfFile : public CMetaFileBase
{
public:
......
......@@ -18,7 +18,6 @@ namespace MetaFile
{
if (BS_DIBPATTERN == BrushStyle && L"" != DibPatternPath)
{
// ::_wunlink(DibPatternPath.c_str());
NSFile::CFileBinary::Remove(DibPatternPath);
}
......
......@@ -5,6 +5,7 @@
#include "../Wmf/WmfUtils.h"
#include "../Wmf/WmfTypes.h"
#include "../../common/Types.h"
#include "../Common/MetaFileObjects.h"
namespace MetaFile
{
......@@ -28,6 +29,7 @@ namespace MetaFile
}
};
class CEmfLogBrushEx : public CEmfObjectBase
{
public:
......@@ -41,14 +43,14 @@ namespace MetaFile
void SetDibPattern(unsigned char* pBuffer, unsigned int ulWidth, unsigned int ulHeight);
public:
unsigned int BrushStyle;
unsigned int BrushStyle;
TEmfColor Color;
unsigned int BrushHatch;
unsigned int BrushAlpha;
unsigned int BrushHatch;
unsigned int BrushAlpha;
std::wstring DibPatternPath;
unsigned char* DibBuffer;
unsigned int DibWidth;
unsigned int DibHeigth;
unsigned int DibWidth;
unsigned int DibHeigth;
};
class CEmfLogFont : public CEmfObjectBase
......
......@@ -118,16 +118,11 @@ namespace MetaFile
{
CEmfObjectBase* pObject = oPos->second;
for (int nIndex = 0; nIndex < m_vDCStack.size(); nIndex++)
switch (pObject->GetType())
{
CEmfDC* pDC = m_vDCStack.at(nIndex);
switch (pObject->GetType())
{
case EMF_OBJECT_BRUSH: m_pDC->SetBrush((CEmfLogBrushEx*)pObject); break;
case EMF_OBJECT_FONT: m_pDC->SetFont((CEmfLogFont*)pObject); break;
case EMF_OBJECT_PEN: m_pDC->SetPen((CEmfLogPen*)pObject); break;
}
case EMF_OBJECT_BRUSH: m_pDC->SetBrush((CEmfLogBrushEx*)pObject); break;
case EMF_OBJECT_FONT: m_pDC->SetFont((CEmfLogFont*)pObject); break;
case EMF_OBJECT_PEN: m_pDC->SetPen((CEmfLogPen*)pObject); break;
}
}
}
......@@ -153,12 +148,17 @@ namespace MetaFile
if (m_mObjects.end() != oPos)
{
CEmfObjectBase* pObject = oPos->second;
switch (pObject->GetType())
for (int nIndex = 0; nIndex < m_vDCStack.size(); nIndex++)
{
case EMF_OBJECT_BRUSH: m_pDC->RemoveBrush((CEmfLogBrushEx*)pObject); break;
case EMF_OBJECT_FONT: m_pDC->RemoveFont((CEmfLogFont*)pObject); break;
case EMF_OBJECT_PEN: m_pDC->RemovePen((CEmfLogPen*)pObject); break;
CEmfDC* pDC = m_vDCStack.at(nIndex);
switch (pObject->GetType())
{
case EMF_OBJECT_BRUSH: pDC->RemoveBrush((CEmfLogBrushEx*)pObject); break;
case EMF_OBJECT_FONT: pDC->RemoveFont((CEmfLogFont*)pObject); break;
case EMF_OBJECT_PEN: pDC->RemovePen((CEmfLogPen*)pObject); break;
}
}
delete pObject;
......
......@@ -7,6 +7,8 @@
#include "EmfObjects.h"
#include "EmfClip.h"
#include "../Common/MetaFilePlayer.h"
namespace MetaFile
{
class CEmfFile;
......
......@@ -4,6 +4,9 @@
#include "../../raster/BgraFrame.h"
#include "Emf/RendererOutput.h"
#ifndef NEW_WMF
#include "Wmf/RendererOutput.h"
#endif
namespace MetaFile
{
......@@ -34,7 +37,12 @@ namespace MetaFile
{
// Wmf
m_oWmfFile.OpenFromFile(wsFilePath);
#ifdef NEW_WMF
m_oWmfFile.Scan();
#else
m_oWmfFile.Scan(&m_oWmfRect);
#endif
if (!m_oWmfFile.CheckError())
{
......@@ -68,6 +76,8 @@ namespace MetaFile
if (c_lMetaWmf == m_lType)
{
#ifdef NEW_WMF
#else
double dRendererDpix, dRendererDpiY;
pRenderer->get_DpiX(&dRendererDpix);
pRenderer->get_DpiY(&dRendererDpiY);
......@@ -108,6 +118,7 @@ namespace MetaFile
TWmfRectF oRect;
m_oWmfFile.Play(&oRect);
#endif
}
else if (c_lMetaEmf == m_lType)
{
......
#ifndef _METAFILE_H
#define _METAFILE_H
#define NEW_WMF 1
#include "../../fontengine/ApplicationFonts.h"
#include "../../graphics/IRenderer.h"
#include "Wmf/WmfFile.h"
#include "Wmf/RendererOutput.h"
#include "Emf/EmfFile.h"
namespace MetaFile
......
......@@ -87,6 +87,7 @@
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\..\agg-2.4\include;..\..\freetype-2.5.2\include;..\..\cximage\jasper\include;..\..\cximage\jpeg;..\..\cximage\png;..\..\cximage\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4005;4018</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
......@@ -148,6 +149,9 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Common.h" />
<ClInclude Include="Common\MetaFile.h" />
<ClInclude Include="Common\MetaFileObjects.h" />
<ClInclude Include="Common\MetaFilePlayer.h" />
<ClInclude Include="Emf\EmfClip.h" />
<ClInclude Include="Emf\EmfFile.h" />
<ClInclude Include="Emf\EmfObjects.h" />
......@@ -168,13 +172,16 @@
<ClInclude Include="Wmf\WmfColor.h" />
<ClInclude Include="Wmf\WmfFile.h" />
<ClInclude Include="Wmf\WmfMemory.h" />
<ClInclude Include="Wmf\WmfObjects.h" />
<ClInclude Include="Wmf\WmfOutputDevice.h" />
<ClInclude Include="Wmf\WmfPlayer.h" />
<ClInclude Include="Wmf\WmfRegion.h" />
<ClInclude Include="Wmf\WmfTypes.h" />
<ClInclude Include="Wmf\WmfUtils.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Common.cpp" />
<ClCompile Include="Common\MetaFilePlayer.cpp" />
<ClCompile Include="Emf\EmfClip.cpp" />
<ClCompile Include="Emf\EmfObjects.cpp" />
<ClCompile Include="Emf\EmfPath.cpp" />
......@@ -182,6 +189,8 @@
<ClCompile Include="MetaFile.cpp" />
<ClCompile Include="stdafx.cpp" />
<ClCompile Include="TestMain.cpp" />
<ClCompile Include="Wmf\WmfObjects.cpp" />
<ClCompile Include="Wmf\WmfPlayer.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
......
......@@ -19,6 +19,9 @@
<Filter Include="Emf">
<UniqueIdentifier>{4c9bc033-8ce8-4711-9c98-6a7605147e5f}</UniqueIdentifier>
</Filter>
<Filter Include="Common">
<UniqueIdentifier>{3f315308-1def-4dee-98fd-79d007d99cf3}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Wmf\RendererOutput.h">
......@@ -96,6 +99,21 @@
<ClInclude Include="Emf\EmfClip.h">
<Filter>Emf</Filter>
</ClInclude>
<ClInclude Include="Wmf\WmfPlayer.h">
<Filter>Wmf</Filter>
</ClInclude>
<ClInclude Include="Wmf\WmfObjects.h">
<Filter>Wmf</Filter>
</ClInclude>
<ClInclude Include="Common\MetaFilePlayer.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Common\MetaFileObjects.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Common\MetaFile.h">
<Filter>Common</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="TestMain.cpp">
......@@ -122,5 +140,14 @@
<ClCompile Include="Emf\EmfClip.cpp">
<Filter>Emf</Filter>
</ClCompile>
<ClCompile Include="Wmf\WmfPlayer.cpp">
<Filter>Wmf</Filter>
</ClCompile>
<ClCompile Include="Wmf\WmfObjects.cpp">
<Filter>Wmf</Filter>
</ClCompile>
<ClCompile Include="Common\MetaFilePlayer.cpp">
<Filter>Common</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
This diff is collapsed.
#include "WmfObjects.h"
#include "../../../raster/ImageFileFormatChecker.h"
#include "../../../graphics/Image.h"
namespace MetaFile
{
CWmfBrush::CWmfBrush() : Color(255, 255, 255)
{
BrushStyle = BS_SOLID;
BrushHatch = HS_HORIZONTAL;
DibPatternPath = L"";
DibBuffer = NULL;
DibWidth = 0;
DibHeigth = 0;
}
CWmfBrush::CWmfBrush(TWmfLogBrush& oBrush)
{
BrushStyle = oBrush.BrushStyle;
Color = oBrush.Color;
BrushHatch = oBrush.BurshHatch;
DibPatternPath = L"";
DibBuffer = NULL;
DibWidth = 0;
DibHeigth = 0;
}
CWmfBrush::~CWmfBrush()
{
if (BS_DIBPATTERN == BrushStyle && L"" != DibPatternPath)
{
NSFile::CFileBinary::Remove(DibPatternPath);
}
if (DibBuffer)
delete[] DibBuffer;
}
void CWmfBrush::SetDibPattern(unsigned char* pBuffer, unsigned int ulWidth, unsigned int ulHeight)
{
DibBuffer = pBuffer;
DibWidth = ulWidth;
DibHeigth = ulHeight;
if (ulWidth <= 0 || ulHeight <= 0)
return;
unsigned int ulBufferSize = 4 * ulWidth * ulHeight;
Aggplus::CImage oImage;
BYTE* pBufferPtr = new BYTE[ulBufferSize];
oImage.Create(pBufferPtr, ulWidth, ulHeight, 4 * ulWidth);
// pBufferPtr
for (unsigned int ulIndex = 0; ulIndex < ulBufferSize; ulIndex += 4)
{
pBufferPtr[0] = (unsigned char)pBuffer[ulIndex + 0];
pBufferPtr[1] = (unsigned char)pBuffer[ulIndex + 1];
pBufferPtr[2] = (unsigned char)pBuffer[ulIndex + 2];
pBufferPtr[3] = (unsigned char)pBuffer[ulIndex + 3];
pBufferPtr += 4;
}
FILE *pTempFile = NULL;
std::wstring wsTempFileName;
if (!WmfOpenTempFile(&wsTempFileName, &pTempFile, L"wb", L".emf0", NULL))
return;
::fclose(pTempFile);
oImage.SaveFile(wsTempFileName, _CXIMAGE_FORMAT_PNG);
BrushStyle = BS_DIBPATTERN;
DibPatternPath = wsTempFileName;
}
}
#ifndef _WMF_OBJECTS_H
#define _WMF_OBJECTS_H
#include "WmfTypes.h"
#include "WmfUtils.h"
namespace MetaFile
{
typedef enum
{
WMF_OBJECT_UNKNOWN = 0x00,
WMF_OBJECT_BRUSH = 0x01,
WMF_OBJECT_FONT = 0x02,
WMF_OBJECT_PEN = 0x03,
WMF_OBJECT_PALETTE = 0x04,
WMF_OBJECT_REGION = 0x05
} EWmfObjectType;
class CWmfObjectBase
{
public:
CWmfObjectBase(){}
virtual ~CWmfObjectBase(){}
virtual EWmfObjectType GetType()
{
return WMF_OBJECT_UNKNOWN;
}
};
class CWmfBrush : public CWmfObjectBase
{
public:
CWmfBrush();
CWmfBrush(TWmfLogBrush& oBrush);
virtual ~CWmfBrush();
virtual EWmfObjectType GetType()
{
return WMF_OBJECT_BRUSH;
}
void SetDibPattern(unsigned char* pBuffer, unsigned int unWidth, unsigned int unHeight);
public:
unsigned short BrushStyle;
TWmfColor Color;
unsigned short BrushHatch;
std::wstring DibPatternPath;
unsigned char* DibBuffer;
unsigned int DibWidth;
unsigned int DibHeigth;
};
class CWmfFont : public CWmfObjectBase
{
public:
CWmfFont()
{
::memset(Facename, 0x00, 32);
}
~CWmfFont()
{
}
virtual EWmfObjectType GetType()
{
return WMF_OBJECT_FONT;
}
public:
short Height;
short Width;
short Escapement;
short Orientation;
short Weight;
unsigned char Italic;
unsigned char Underline;
unsigned char StrikeOut;
unsigned char CharSet;
unsigned char OutPrecision;
unsigned char ClipPrecision;
unsigned char Quality;
unsigned char PitchAndFamily;
unsigned char Facename[32]; // 32
};
class CWmfPalette : public CWmfObjectBase
{
public:
CWmfPalette()
{
aPaletteEntries = NULL;
NumberOfEntries = 0;
}
~CWmfPalette()
{
if (aPaletteEntries)
delete[] aPaletteEntries;
}
virtual EWmfObjectType GetType()
{
return WMF_OBJECT_PALETTE;
}
public:
unsigned short Start;
unsigned short NumberOfEntries;
TWmfPaletteEntry* aPaletteEntries;
};
class CWmfPen : public CWmfObjectBase
{
public:
CWmfPen()
{
}
~CWmfPen()
{
}
virtual EWmfObjectType GetType()
{
return WMF_OBJECT_PEN;
}
public:
unsigned short PenStyle;
TWmfPointS Width;
TWmfColor Color;
};
class CWmfRegion : public CWmfObjectBase
{
public:
CWmfRegion()
{
}
~CWmfRegion()
{
}
virtual EWmfObjectType GetType()
{
return WMF_OBJECT_REGION;
}
public:
short nextInChain; //
short ObjectType; //
short RegionSize;
short ScanCount;
short MaxScan;
TWmfRect BoundingRectangle;
TWmfScanObject* aScans;
};
}
#endif //_WMF_OBJECTS_H
\ No newline at end of file
This diff is collapsed.
#ifndef _WMF_PLAYER_H
#define _WMF_PLAYER_H
#include <map>
#include <vector>
#include "WmfObjects.h"
namespace MetaFile
{
class CWmfDC;
class CWmfFile;
class CWmfPlayer
{
public:
CWmfPlayer(CWmfFile* pFile);
~CWmfPlayer();
void Clear();
CWmfDC* SaveDC();
CWmfDC* RestoreDC();
CWmfDC* GetDC();
void RegisterObject(CWmfObjectBase* pObject);
void SelectObject(unsigned short ushIndex);
void SelectPalette(unsigned short ushIndex);
void DeleteObject(unsigned short ushIndex);
private:
typedef std::map <unsigned int, CWmfObjectBase*> CWmfObjectMap;
CWmfDC* m_pDC;
std::vector<CWmfDC*> m_vDCStack;
CWmfFile* m_pFile;
CWmfObjectMap m_mObjects;
unsigned short m_ushIndex;
std::vector<unsigned short> m_vAvailableIndexes;
};
class CWmfDC
{
public:
CWmfDC();
~CWmfDC();
CWmfDC* Copy();
void SetBrush(CWmfBrush* pBrush);
void RemoveBrush(CWmfBrush* pBrush);
CWmfBrush* GetBrush();
void SetPen(CWmfPen* pPen);
void RemovePen(CWmfPen* pPen);
CWmfPen* GetPen();
void SetPalette(CWmfPalette* pPalette);
void RemovePalette(CWmfPalette* pPalette);
CWmfPalette* GetPalette();
void SetFont(CWmfFont* pFont);
void RemoveFont(CWmfFont* pFont);
CWmfFont* GetFont();
void SetRegion(CWmfRegion* pRegion);
void RemoveRegion(CWmfRegion* pRegion);
CWmfRegion* GetRegion();
void SetMapMode(unsigned short ushMapMode);
unsigned int GetMapMode();
double GetPixelWidth();
double GetPixelHeight();
TWmfWindow* GetWindow();
void SetWindowOrg(short shX, short shY);
void SetWindowExt(short shW, short shH);
void SetWindowOff(short shX, short shY);
void SetWindowScale(double dX, double dY);
TWmfWindow* GetViewport();
void SetViewportOrg(short shX, short shY);
void SetViewportExt(short shW, short shH);
void SetViewportOff(short shX, short shY);
void SetViewportScale(double dX, double dY);
void SetTextColor(TWmfColor& oColor);
TWmfColor& GetTextColor();
void SetTextBgColor(TWmfColor& oColor);
TWmfColor& GetTextBgColor();
TWmfPointS& GetCurPos();
void SetCurPos(TWmfPointS& oPoint);
void SetCurPos(short shX, short shY);
void SetTextBgMode(unsigned short ushMode);
unsigned short GetTextBgMode();
void SetLayout(unsigned short ushLayout);
unsigned short GetLayout();
void SetPolyFillMode(unsigned short ushMode);
unsigned short GetPolyFillMode();
void SetRop2Mode(unsigned short ushMode);
unsigned short GetRop2Mode();
void SetStretchBltMode(unsigned short ushMode);
unsigned short GetStretchBltMode();
void SetTextAlign(unsigned short ushTextAlign);
unsigned short GetTextAlign();
void SetCharSpacing(unsigned short ushCharSpacing);
unsigned short GetCharSpacing();
private:
void SetPixelWidth(double dW);
void SetPixelHeight(double dH);
bool UpdatePixelMetrics();
private:
CWmfBrush m_oDefaultBrush;
CWmfPen m_oDefaultPen;
CWmfBrush* m_pBrush;
CWmfPen* m_pPen;
CWmfPalette* m_pPalette;
CWmfFont* m_pFont;
CWmfRegion* m_pRegion;
unsigned short m_ushMapMode;
double m_dPixelWidth;
double m_dPixelHeight;
TWmfWindow m_oWindow;
TWmfWindow m_oViewport;
TWmfColor m_oTextColor;
TWmfColor m_oTextBgColor;
TWmfPointS m_oCurPos;
unsigned short m_ushTextBgMode;
unsigned short m_ushLayout;
unsigned short m_ushPolyFillMode;
unsigned short m_ushRop2Mode;
unsigned short m_ushStretchBltMode;
unsigned short m_ushTextAlign;
unsigned short m_ushCharSpacing;
};
//class CEmfDC
//{
//public:
// CEmfDC();
// ~CEmfDC();
// CEmfDC* Copy();
// TEmfXForm* GetTransform();
// TEmfXForm* GetInverseTransform();
// void MultiplyTransform(TEmfXForm& oForm, unsigned int ulMode);
// void SetMiterLimit(unsigned int ulMiter);
// unsigned int GetMiterLimit();
// CEmfClip* GetClip();
// void ClipToPath(CEmfPath* pPath, unsigned int unMode);
//private:
// TEmfXForm m_oTransform;
// TEmfXForm m_oInverseTransform;
// unsigned int m_ulMiterLimit;
// CEmfClip m_oClip;
//};
}
#endif //_WMF_PLAYER_H
\ No newline at end of file
......@@ -851,4 +851,142 @@ enum EWmfBitCount
#define META_CREATEBRUSHINDIRECT 0x02FC
#define META_CREATEREGION 0x06FF
namespace MetaFile
{
#define META_EOF 0x0000
struct TWmfColor
{
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a; //Reserved Must be 0x00
TWmfColor()
{
r = 0;
g = 0;
b = 0;
}
TWmfColor(unsigned char _r, unsigned char _g, unsigned char _b)
{
r = _r;
g = _g;
b = _b;
}
void Set(unsigned char _r, unsigned char _g, unsigned char _b)
{
r = _r;
g = _g;
b = _b;
}
void Init()
{
r = 0;
g = 0;
b = 0;
a = 0;
}
void Copy(TWmfColor* pOther)
{
r = pOther->r;
g = pOther->g;
b = pOther->b;
a = pOther->a;
}
TWmfColor& operator=(TWmfColor& oColor)
{
r = oColor.r;
g = oColor.g;
b = oColor.b;
a = oColor.a;
return *this;
}
};
struct TWmfPaletteEntry
{
unsigned char Values;
unsigned char Blue;
unsigned char Green;
unsigned char Red;
};
struct TWmfPointS
{
short x;
short y;
};
struct TWmfRect
{
short Left;
short Top;
short Right;
short Bottom;
};
struct TWmfPlaceable
{
unsigned int Key;
unsigned short HWmf;
TWmfRect BoundingBox;
unsigned short Inch;
unsigned int Reserved;
unsigned short Checksum;
};
struct TWmfHeader
{
unsigned short Type;
unsigned short HeaderSize;
unsigned short Version;
unsigned int Size;
unsigned short NumberOfObjects;
unsigned int MaxRecord;
unsigned short NumberOfMembers;
};
struct TWmfScanLine
{
unsigned short Left;
unsigned short Right;
};
struct TWmfScanObject
{
unsigned short Count;
unsigned short Top;
unsigned short Bottom;
TWmfScanLine* ScanLines;
unsigned short Count2;
};
struct TWmfWindow
{
short x;
short y;
short w;
short h;
void Init()
{
x = 0;
y = 0;
w = 1024;
h = 1024;
}
void Copy(TWmfWindow& oOther)
{
x = oOther.x;
y = oOther.y;
w = oOther.w;
h = oOther.h;
}
};
struct TWmfLogBrush
{
unsigned short BrushStyle;
TWmfColor Color;
unsigned short BurshHatch;
};
}
#endif /* _WMF_TYPES_H_ */
\ No newline at end of file
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