Commit a5188a04 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

StarView Metafile по новому ..

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62703 954022d7-b5bf-4e40-9824-e11837661b57
parent 7641665f
......@@ -7279,6 +7279,7 @@ DesktopEditor/raster/Jp2 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/StarView svnc_tsvn_003alogminsize=5
DesktopEditor/raster/Metafile/Wmf svnc_tsvn_003alogminsize=5
DesktopEditor/raster/SvmFile svnc_tsvn_003alogminsize=5
DesktopEditor/raster/SvmFile/Source svnc_tsvn_003alogminsize=5
......@@ -5,7 +5,7 @@
#include "MetaFileUtils.h"
#include "MetaFileObjects.h"
#include "MetaFileClip.h"
#include "../../fontengine/FontManager.h"
#include "../../../fontengine/FontManager.h"
namespace MetaFile
{
......
#include "MetaFileUtils.h"
#include "../../raster/ImageFileFormatChecker.h"
#include "../../raster/BgraFrame.h"
#include "../../ImageFileFormatChecker.h"
#include "../../BgraFrame.h"
#include <time.h>
#include <math.h>
......
......@@ -179,6 +179,11 @@ namespace MetaFile
nValue = ReadChar();
return *this;
}
CDataStream& operator>>(bool& nValue)
{
nValue = !!ReadChar();
return *this;
}
CDataStream& operator>>(short& nValue)
{
nValue = ReadShort();
......
......@@ -16,8 +16,10 @@ namespace MetaFile
CFontsCache* pMeasurerCache = new CFontsCache();
pMeasurerCache->SetStreams(pAppFonts->GetStreams());
m_pFontManager->SetOwnerCache(pMeasurerCache);
m_oWmfFile.SetFontManager(m_pFontManager);
m_oEmfFile.SetFontManager(m_pFontManager);
m_oSvmFile.SetFontManager(m_pFontManager);
m_lType = 0;
}
......@@ -42,33 +44,48 @@ namespace MetaFile
m_pFontManager->SetOwnerCache(pMeasurerCache);
m_oWmfFile.SetFontManager(m_pFontManager);
m_oEmfFile.SetFontManager(m_pFontManager);
m_oSvmFile.SetFontManager(m_pFontManager);
//------------------------------------------------------
// Wmf
m_oWmfFile.OpenFromFile(wsFilePath);
m_oWmfFile.Scan();
if (!m_oWmfFile.CheckError())
if (m_oWmfFile.OpenFromFile(wsFilePath) == true)
{
m_lType = c_lMetaWmf;
return true;
m_oWmfFile.Scan();
if (!m_oWmfFile.CheckError())
{
m_lType = c_lMetaWmf;
return true;
}
m_oWmfFile.Close();
}
// Wmf
if (m_oEmfFile.OpenFromFile(wsFilePath) == true)
{
m_oEmfFile.Scan();
// Wmf, Emf
m_oWmfFile.Close();
m_oEmfFile.OpenFromFile(wsFilePath);
m_oEmfFile.Scan();
if (!m_oEmfFile.CheckError())
{
m_lType = c_lMetaEmf;
return true;
}
if (!m_oEmfFile.CheckError())
{
m_lType = c_lMetaEmf;
return true;
m_oEmfFile.Close();
}
// Emf
m_oEmfFile.Close();
if (m_oSvmFile.OpenFromFile(wsFilePath) == true)
{
m_oSvmFile.Scan();
if (!m_oSvmFile.CheckError())
{
m_lType = c_lMetaSvm;
return true;
}
m_oSvmFile.Close();
}
return false;
};
......@@ -91,7 +108,12 @@ namespace MetaFile
m_oEmfFile.SetOutputDevice((IOutputDevice*)&oEmfOut);
m_oEmfFile.PlayMetaFile();
}
else if (c_lMetaSvm == m_lType)
{
CMetaFileRenderer oSvmOut(&m_oSvmFile, pRenderer, dX, dY, dWidth, dHeight);
m_oSvmFile.SetOutputDevice((IOutputDevice*)&oSvmOut);
m_oSvmFile.PlayMetaFile();
}
pRenderer->EndCommand(c_nImageType);
return true;
};
......@@ -124,6 +146,14 @@ namespace MetaFile
*pdW = pRect->lRight - pRect->lLeft;
*pdH = pRect->lBottom - pRect->lTop;
}
else if (c_lMetaSvm == m_lType)
{
TRect* pRect = m_oSvmFile.GetBounds();
*pdX = pRect->nLeft;
*pdY = pRect->nTop;
*pdW = pRect->nRight - pRect->nLeft;
*pdH = pRect->nBottom - pRect->nTop;
}
else
{
*pdX = 0;
......
......@@ -6,13 +6,14 @@
#include "Wmf/WmfFile.h"
#include "Emf/EmfFile.h"
#include "StarView/SvmFile.h"
namespace MetaFile
{
const int c_lMetaWmf = 0x01;
const int c_lMetaEmf = 0x02;
const int c_lMetaSvg = 0x04;
// )
const int c_lMetaSvm = 0x05;
class CMetaFile
{
......@@ -34,6 +35,7 @@ namespace MetaFile
CFontManager* m_pFontManager;
CWmfFile m_oWmfFile;
CEmfFile m_oEmfFile;
CSvmFile m_oSvmFile;
int m_lType;
};
}
......
......@@ -165,6 +165,11 @@
<ClInclude Include="Emf\EmfPlayer.h" />
<ClInclude Include="Emf\EmfTypes.h" />
<ClInclude Include="MetaFile.h" />
<ClInclude Include="StarView\SvmAbstractPlayer.h" />
<ClInclude Include="StarView\SvmEnums.h" />
<ClInclude Include="StarView\SvmPlayer.h" />
<ClInclude Include="StarView\SvmFile.h" />
<ClInclude Include="StarView\SvmObjects.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="Wmf\WmfClip.h" />
<ClInclude Include="Wmf\WmfFile.h" />
......@@ -180,6 +185,9 @@
<ClCompile Include="Emf\EmfPath.cpp" />
<ClCompile Include="Emf\EmfPlayer.cpp" />
<ClCompile Include="MetaFile.cpp" />
<ClCompile Include="StarView\SvmPlayer.cpp" />
<ClCompile Include="StarView\SvmFile.cpp" />
<ClCompile Include="StarView\SvmObjects.cpp" />
<ClCompile Include="stdafx.cpp" />
<ClCompile Include="TestMain.cpp" />
<ClCompile Include="Wmf\WmfClip.cpp" />
......
......@@ -22,6 +22,9 @@
<Filter Include="Common">
<UniqueIdentifier>{3f315308-1def-4dee-98fd-79d007d99cf3}</UniqueIdentifier>
</Filter>
<Filter Include="StarView">
<UniqueIdentifier>{1139b56c-7880-45fe-b821-3e054d70deaf}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Wmf\WmfFile.h">
......@@ -84,6 +87,21 @@
<ClInclude Include="Common\MetaFileUtils.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="StarView\SvmEnums.h">
<Filter>StarView</Filter>
</ClInclude>
<ClInclude Include="StarView\SvmPlayer.h">
<Filter>StarView</Filter>
</ClInclude>
<ClInclude Include="StarView\SvmAbstractPlayer.h">
<Filter>StarView</Filter>
</ClInclude>
<ClInclude Include="StarView\SvmFile.h">
<Filter>StarView</Filter>
</ClInclude>
<ClInclude Include="StarView\SvmObjects.h">
<Filter>StarView</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="TestMain.cpp">
......@@ -122,5 +140,14 @@
<ClCompile Include="Common\MetaFileUtils.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="StarView\SvmPlayer.cpp">
<Filter>StarView</Filter>
</ClCompile>
<ClCompile Include="StarView\SvmFile.cpp">
<Filter>StarView</Filter>
</ClCompile>
<ClCompile Include="StarView\SvmObjects.cpp">
<Filter>StarView</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
This diff is collapsed.
/*
Copyright 2009 Inge Wallin <inge@lysator.liu.se>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CSvmAbstractPlayer_H
#define CSvmAbstractPlayer_H
#include "SvmEnums.h"
#include "SvmStructs.h"
#include "SvmGraphicsContext.h"
class TPoint;
class TRect;
class TPolygon;
class TString;
/**
\file
Primary definitions for SVM output backend
*/
/**
Namespace for StarView Metafile (SVM) classes
*/
namespace MetaFile
{
/**
Abstract output strategy for SVM Parser
*/
class CSvmAbstractPlayer
{
public:
CSvmAbstractPlayer() {};
virtual ~CSvmAbstractPlayer() {};
/**
Initialisation routine
\param header the SVM Header record
*/
virtual void init(const SvmHeader &header) = 0;
/**
Cleanup routine
This function is called when the painting is done. Any
initializations that are done in init() can be undone here if
necessary.
\param header the SVM Header record
*/
virtual void cleanup( /*const Header *header*/ ) = 0;
/**
Close-out routine
*/
virtual void eof() = 0;
virtual void rect( SvmGraphicsContext &context, const TRect &rect ) = 0;
/**
Handler META_POLYLINE_ACTION
This action type specifies how to output a multi-segment line
(unfilled polyline).
\param context the graphics context to be used when drawing the polyline
\param polygon the sequence of points that describe the line
\note the line is not meant to be closed (i.e. do not connect
the last point to the first point) or filled.
*/
virtual void polyLine(SvmGraphicsContext &context, const TPolygon &polyline) = 0;
virtual void polygon(SvmGraphicsContext &context, const TPolygon &polygon) = 0;
virtual void textArray(SvmGraphicsContext &context,
const TPoint &point, const std::wstring & string) = 0;
};
}
#endif
#ifndef SVMENUMS_H
#define SVMENUMS_H
/**
Namespace for StarView Metafile (SVM) classes
*/
namespace MetaFile
{
/**
Action types
See the SPEC Section 2.1.1.1
*/
enum ActionType
{
META_NULL_ACTION = 0,
META_PIXEL_ACTION = 100,
META_POINT_ACTION = 101,
META_LINE_ACTION = 102,
META_RECT_ACTION = 103,
META_ROUNDRECT_ACTION = 104,
META_ELLIPSE_ACTION = 105,
META_ARC_ACTION = 106,
META_PIE_ACTION = 107,
META_CHORD_ACTION = 108,
META_POLYLINE_ACTION = 109,
META_POLYGON_ACTION = 110,
META_POLYPOLYGON_ACTION = 111,
META_TEXT_ACTION = 112,
META_TEXTARRAY_ACTION = 113,
META_STRETCHTEXT_ACTION = 114,
META_TEXTRECT_ACTION = 115,
META_BMP_ACTION = 116,
META_BMPSCALE_ACTION = 117,
META_BMPSCALEPART_ACTION = 118,
META_BMPEX_ACTION = 119,
META_BMPEXSCALE_ACTION = 120,
META_BMPEXSCALEPART_ACTION = 121,
META_MASK_ACTION = 122,
META_MASKSCALE_ACTION = 123,
META_MASKSCALEPART_ACTION = 124,
META_GRADIENT_ACTION = 125,
META_HATCH_ACTION = 126,
META_WALLPAPER_ACTION = 127,
META_CLIPREGION_ACTION = 128,
META_ISECTRECTCLIPREGION_ACTION = 129,
META_ISECTREGIONCLIPREGION_ACTION = 130,
META_MOVECLIPREGION_ACTION = 131,
META_LINECOLOR_ACTION = 132,
META_FILLCOLOR_ACTION = 133,
META_TEXTCOLOR_ACTION = 134,
META_TEXTFILLCOLOR_ACTION = 135,
META_TEXTALIGN_ACTION = 136,
META_MAPMODE_ACTION = 137,
META_FONT_ACTION = 138,
META_PUSH_ACTION = 139,
META_POP_ACTION = 140,
META_RASTEROP_ACTION = 141,
META_TRANSPARENT_ACTION = 142,
META_EPS_ACTION = 143,
META_REFPOINT_ACTION = 144,
META_TEXTLINECOLOR_ACTION = 145,
META_TEXTLINE_ACTION = 146,
META_FLOATTRANSPARENT_ACTION = 147,
META_GRADIENTEX_ACTION = 148,
META_LAYOUTMODE_ACTION = 149,
META_TEXTLANGUAGE_ACTION = 150,
META_OVERLINECOLOR_ACTION = 151,
META_RENDERGRAPHIC_ACTION = 152,
META_COMMENT_ACTION = 512
};
#define META_LAST_ACTION 153 //META_SVG_SOMETHING_ACTION
/**
Mtf (FIXME)
See the SPEC Section 2.1.1.2
*/
enum MtfType
{
MTF_CONVERSION_NONE = 0,
MTF_CONVERSION_1BIT_THRESHOLD = 1,
MTF_CONVERSION_8BIT_GREYS = 2
};
// ----------------------------------------------------------------
// Flags
// ----------------------------------------------------------------
/**
Mirror flags
See the SPEC Section 2.1.2.1
*/
enum MtfMirrorType
{
MTF_MIRROR_NONE = 0x00000000,
MTF_MIRROR_HORZ = 0x00000001,
MTF_MIRROR_VERT = 0x00000002
};
}
#endif
This diff is collapsed.
This diff is collapsed.
#include "SvmObjects.h"
namespace MetaFile
{
void soakBytes(CDataStream &stream, int numBytes)
{
unsigned char scratch;
for (int i = 0; i < numBytes; ++i)
{
stream >> scratch;
}
}
void parseString(CDataStream &stream, std::wstring &string)
{
unsigned short length;
stream >> length;
for (unsigned int i = 0; i < length; ++i)
{
unsigned char ch;
stream >> ch;
string += char(ch);
}
}
VersionCompat::VersionCompat()
: version(0)
, length(0)
{
}
VersionCompat::VersionCompat(CDataStream &stream)
{
stream >> version;
stream >> length;
}
Fraction::Fraction()
: numerator(1)
, denominator(1)
{
}
Fraction::Fraction(CDataStream &stream)
{
stream >> numerator;
stream >> denominator;
}
MapMode::MapMode()
: version()
, unit(0)
, scaleX()
, scaleY()
, isSimple(true)
{
}
MapMode::MapMode(CDataStream &stream)
{
stream >> *this;
}
CDataStream& operator>>(CDataStream &stream, VersionCompat &compat)
{
stream >> compat.version;
stream >> compat.length;
return stream;
}
CDataStream& operator>>(CDataStream &stream, Fraction &fract)
{
stream >> fract.numerator;
stream >> fract.denominator;
return stream;
}
CDataStream& operator>>(CDataStream &stream, MapMode &mm)
{
stream >> mm.version;
stream >> mm.unit;
stream >> mm.origin;
stream >> mm.scaleX;
stream >> mm.scaleY;
stream >> mm.isSimple; // FIXME: how many bytes?
return stream;
}
SvmHeader::SvmHeader()
: versionCompat()
, compressionMode()
, mapMode()
, boundRect()
, actionCount(0)
{
}
SvmHeader::SvmHeader(CDataStream &stream)
{
stream >> *this;
}
CDataStream& operator>>(CDataStream &stream, SvmHeader &header)
{
stream >> header.versionCompat;
stream >> header.compressionMode;
stream >> header.mapMode;
unsigned int height, width;
stream >> width;
stream >> height;
header.boundRect.nBottom = height;
header.boundRect.nRight = width;
stream >> header.actionCount;
if (header.versionCompat.version > 1)
soakBytes(stream, 1);
return stream;
}
TSvmPoint::TSvmPoint(CDataStream &stream)
{
stream >> *this;
}
TSvmRect::TSvmRect()
{
l = t = r = b = 0;
}
CDataStream& operator>>(CDataStream &stream, TSvmPoint &p)
{
stream >> p.x;
stream >> p.y;
return stream;
}
CSvmBrush::CSvmBrush() : Color(255, 255, 255)
{
BrushStyle = BS_SOLID;
BrushHatch = HS_HORIZONTAL;
}
CSvmBrush::CSvmBrush(CSvmBrush& oBrush)
{
BrushStyle = oBrush.BrushStyle;
Color = oBrush.Color;
BrushHatch = oBrush.BrushHatch;
}
int CSvmBrush::GetColor()
{
return METAFILE_RGBA(Color.r, Color.g, Color.b);
}
unsigned int CSvmBrush::GetStyle()
{
return BrushStyle;
}
unsigned int CSvmBrush::GetHatch()
{
return BrushHatch;
}
unsigned int CSvmBrush::GetAlpha()
{
return 255;
}
int CSvmPen::GetColor()
{
return METAFILE_RGBA(Color.r, Color.g, Color.b);
}
TSvmRect::TSvmRect(CDataStream &stream)
{
stream >> *this;
}
CDataStream& operator>>(CDataStream &stream, TSvmRect &p)
{
stream >> p.l;
stream >> p.r;
stream >> p.t;
stream >> p.b;
return stream;
}
TSvmPolygon::TSvmPolygon(CDataStream &stream)
{
stream >> *this;
}
CDataStream& operator>>(CDataStream &stream, TSvmPolygon &p)
{
stream >> p.count;
for (int i = 0; i < p.count; i++)
{
TSvmPoint point;
stream >> point;
p.points.push_back(point);
}
return stream;
}
CDataStream& operator>>(CDataStream &stream, TSvmColor &c)
{
stream >> c.r;
stream >> c.g;
stream >> c.b;
unsigned char reserv;
stream >> reserv;
return stream;
}
CDataStream& operator>>(CDataStream &stream, CSvmBrush *b)
{
return stream;
}
CDataStream& operator>>(CDataStream &stream, CSvmFont *font)
{
unsigned short version;
unsigned int totalSize;
// the VersionCompat struct
stream >> version;
stream >> totalSize;
// Name and style
std::wstring family;
std::wstring style;
parseString(stream, family);
parseString(stream, style);
font->sFacename = family;
// Font size
unsigned int width;
unsigned int height;
stream >> width;
stream >> height;
font->Width = width;
font->Height = height;
char temp8;
bool tempbool;
unsigned short tempu16;
stream >> tempu16; // charset
stream >> tempu16; // family
stream >> tempu16; // pitch
stream >> tempu16; // weight
if (tempu16 > 0)
font->Weight = tempu16;
stream >> tempu16; // underline
if (tempu16 > 0)
font->Underline= 1;
stream >> tempu16; // strikeout
if (tempu16 > 0)
font->StrikeOut = 1;
stream >> tempu16; // italic
if (tempu16 > 0)
font->Italic = 1;
stream >> tempu16; // language
stream >> tempu16; // width
if (tempu16 > 0)
font->Width = tempu16; //??? todo
stream >> tempu16; // orientation
stream >> tempbool; // wordline
stream >> tempbool; // outline
stream >> tempbool; // shadow
stream >> temp8; // kerning
if (version > 1)
{
stream >> temp8; // relief
stream >> tempu16; // language
stream >> tempbool; // vertical
if (tempbool)
font->Orientation = 2;
stream >> tempu16; // emphasis
}
if (version > 2)
{
stream >> tempu16; // overline
}
// FIXME: Read away the rest of font here to allow for higher versions than 3.
return stream;
}
}
#pragma once
//#include <qglobal.h>
#include "../Common/MetaFileTypes.h"
#include "../Common/MetaFileObjects.h"
#include "../Common/MetaFileUtils.h"
#include "../../../common/File.h"
namespace MetaFile
{
typedef enum
{
SVM_OBJECT_UNKNOWN = 0x00,
SVM_OBJECT_BRUSH = 0x01,
SVM_OBJECT_FONT = 0x02,
SVM_OBJECT_PEN = 0x03//,
//EMF_OBJECT_PALETTE = 0x04
} ESvmObjectType;
class CSvmObjectBase
{
public:
CSvmObjectBase(){}
virtual ~CSvmObjectBase(){}
virtual ESvmObjectType GetType()
{
return SVM_OBJECT_UNKNOWN;
}
};
struct VersionCompat
{
VersionCompat();
VersionCompat(CDataStream &stream);
unsigned short version;
unsigned int length;//32
};
struct Fraction
{
Fraction();
Fraction(CDataStream &stream);
unsigned int numerator;
unsigned int denominator;
};
struct TSvmPoint
{
TSvmPoint(){ x = y = 0; }
TSvmPoint(CDataStream &stream);
int x;
int y;
void Set(int _x, int _y)
{
x = _x;
y = _y;
}
};
struct TSvmSize
{
unsigned int cx;
unsigned int cy;
};
struct MapMode
{
MapMode();
MapMode(CDataStream &stream);
VersionCompat version;
unsigned short unit;
TSvmPoint origin;
Fraction scaleX;
Fraction scaleY;
bool isSimple;
};
struct SvmHeader
{
SvmHeader();
SvmHeader(CDataStream &stream);
VersionCompat versionCompat;
unsigned int compressionMode;
MapMode mapMode;
TRect boundRect;
unsigned int actionCount;
};
struct TSvmRect
{
TSvmRect();
TSvmRect(CDataStream &stream);
int l;
int r;
int t;
int b;
};
struct TSvmPolygon
{
TSvmPolygon(){ count = 0; }
TSvmPolygon(CDataStream &stream);
std::vector<TSvmPoint> points;
unsigned short count;
};
struct TSvmColor
{
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a; //Reserved Must be 0x00
TSvmColor()
{
r = 0; g = 0; b = 0;
}
TSvmColor(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(const TSvmColor& oOther)
{
r = oOther.r; g = oOther.g; b = oOther.b; a = oOther.a;
}
TSvmColor& operator=(const TSvmColor& oColor)
{
r = oColor.r; g = oColor.g; b = oColor.b; a = oColor.a;
return *this;
}
};
struct TSvmWindow
{
int lX;
int lY;
int ulW;
int ulH;
void Init()
{
lX = 0;
lY = 0;
ulW = 1024;
ulH = 1024;
}
void Copy(TSvmWindow* pOther)
{
lX = pOther->lX;
lY = pOther->lY;
ulW = pOther->ulW;
ulH = pOther->ulH;
}
};
class CSvmBrush : public CSvmObjectBase, public IBrush
{
public:
CSvmBrush();
CSvmBrush(CSvmBrush& oBrush);
virtual ~CSvmBrush(){}
virtual ESvmObjectType GetType()
{
return SVM_OBJECT_BRUSH;
}
// IBrush
int GetColor();
unsigned int GetStyle();
unsigned int GetHatch();
unsigned int GetAlpha();
std::wstring GetDibPatterPath(){ return L""; }
public:
unsigned short BrushStyle;
TSvmColor Color;
unsigned short BrushHatch;
};
class CSvmFont : public CSvmObjectBase, public IFont
{
public:
CSvmFont()
{
}
~CSvmFont()
{
}
virtual ESvmObjectType GetType()
{
return SVM_OBJECT_FONT;
}
// IFont
int GetHeight()
{
return (int)Height;
}
std::wstring GetFaceName()
{
return sFacename;
}
int GetWeight()
{
return (int)Weight;
}
bool IsItalic()
{
return (0x01 == Italic ? true : false);
}
bool IsStrikeOut()
{
return (0x01 == StrikeOut ? true : false);
}
bool IsUnderline()
{
return (0x01 == Underline ? true : false);
}
int GetEscapement()
{
return (int)Escapement;
}
int GetCharSet()
{
return (int)CharSet;
}
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;
std::wstring sFacename;
// 32
};
class CSvmPen : public CSvmObjectBase, public IPen
{
public:
CSvmPen()
{
Width.x = 1;
}
~CSvmPen()
{
}
virtual ESvmObjectType GetType()
{
return SVM_OBJECT_PEN;
}
// IPen
int GetColor();
unsigned int GetStyle()
{
return (unsigned int)PenStyle;
}
unsigned int GetWidth()
{
return (unsigned int)Width.x;
}
public:
unsigned short PenStyle;
TSvmPoint Width;
TSvmColor Color;
};
void soakBytes(CDataStream &stream, int numBytes);
void parseString(CDataStream &stream, std::wstring &string);
CDataStream& operator>>(CDataStream &stream, VersionCompat &compat);
CDataStream& operator>>(CDataStream &stream, Fraction &fract);
CDataStream& operator>>(CDataStream &stream, MapMode &mm);
CDataStream& operator>>(CDataStream &stream, SvmHeader &header);
CDataStream& operator>>(CDataStream &stream, TSvmPoint &p);
CDataStream& operator>>(CDataStream &stream, TSvmRect &p);
CDataStream& operator>>(CDataStream &stream, TSvmPolygon &p);
CDataStream& operator>>(CDataStream &stream, TSvmColor &c);
CDataStream& operator>>(CDataStream &stream, CSvmBrush *b);
CDataStream& operator>>(CDataStream &stream, CSvmFont *f);
}
This diff is collapsed.
#ifndef CSvmPlayer_H
#define CSvmPlayer_H
#include "SvmEnums.h"
#include "SvmObjects.h"
#include <map>
#include <vector>
namespace MetaFile
{
class CSvmFile;
class CSvmDC;
class CSvmPlayer
{
public:
CSvmPlayer(CSvmFile *file);
virtual ~CSvmPlayer();
void Clear();
CSvmDC* SaveDC();
CSvmDC* RestoreDC();
CSvmDC* GetDC();
void RegisterObject(CSvmObjectBase* pObject);
void SelectObject(unsigned short ushIndex);
void SelectPalette(unsigned short ushIndex);
void DeleteObject(unsigned short ushIndex);
private:
void InitStockObjects();
void InitStockBrush(bool bNull, unsigned char r, unsigned char g, unsigned char b);
void InitStockPen(bool bNull, unsigned char r, unsigned char g, unsigned char b);
typedef std::map < unsigned int, CSvmObjectBase* > CSvmObjectMap;
CSvmDC* m_pDC;
std::vector<CSvmDC*> m_vDCStack;
CSvmFile* m_pSvmFile;
CSvmObjectMap m_mObjects;
typedef std::map <unsigned int, CWmfObjectBase*> CWmfObjectMap;
unsigned short m_ushIndex;
std::vector<unsigned short> m_vAvailableIndexes;
};
class CSvmDC
{
public:
CSvmDC();
~CSvmDC();
CSvmDC* Copy();
void SetMapMode(MapMode &mapMode);
TXForm* GetTransform();
TXForm* GetInverseTransform();
void MultiplyTransform(TXForm& oForm, unsigned int ulMode);
void SetTextColor(TSvmColor& oColor);
TSvmColor& GetTextColor();
void SetBrush(CSvmBrush* pBrush);
void RemoveBrush(CSvmBrush *pBrush);
CSvmBrush* GetBrush();
void SetFont(CSvmFont* pFont);
void RemoveFont(CSvmFont* pFont);
CSvmFont* GetFont();
void SetTextAlign(unsigned int ulAlign);
unsigned int GetTextAlign();
void SetBgMode(unsigned int ulBgMode);
unsigned int GetBgMode();
void SetBgColor(TSvmColor& oColor);
void SetBgColor(TSvmColor* oColor);
TSvmColor& GetBgColor();
void SetMiterLimit(unsigned int ulMiter);
unsigned int GetMiterLimit();
void SetFillMode(unsigned int ulFillMode);
unsigned int GetFillMode();
void SetPen(CSvmPen* pPen);
void RemovePen(CSvmPen* pPen);
CSvmPen* GetPen();
void SetStretchMode(unsigned int& oMode);
unsigned int GetStretchMode();
double GetPixelWidth();
double GetPixelHeight();
void SetWindowOrigin(TSvmPoint& oPoint);
void SetWindowExtents(TSvmSize& oPoint);
TSvmWindow* GetWindow();
void SetViewportOrigin(TSvmPoint& oPoint);
void SetViewportExtents(TSvmSize& oPoint);
TSvmWindow* GetViewport();
void SetRop2Mode(unsigned int& nMode);
unsigned int GetRop2Mode();
//void SetPalette(CSvmLogPalette* pPalette);
//void RemovePalette(CSvmLogPalette* pPalette);
//CSvmLogPalette* GetPalette();
void SetCurPos(TSvmPoint& oPoint);
void SetCurPos(int lX, int lY);
TSvmPoint& GetCurPos();
//CSvmClip* GetClip();
//void ClipToPath(CSvmPath* pPath, unsigned int unMode);
void SetArcDirection(unsigned int unDirection);
unsigned int GetArcDirection();
private:
void SetPixelWidth(double dPixelW);
void SetPixelHeight(double dPixelH);
bool UpdatePixelMetrics();
private:
unsigned int m_ulMapMode;
CSvmBrush* m_pBrush;
CSvmPen* m_pPen;
CSvmFont* m_pFont;
//CSvmLogPalette* m_pPalette;
TXForm m_oTransform;
TXForm m_oInverseTransform;
TSvmColor m_oTextColor;
TSvmColor m_oBgColor;
unsigned int m_ulTextAlign;
unsigned int m_ulBgMode;
unsigned int m_ulMiterLimit;
unsigned int m_ulFillMode;
unsigned int m_ulStretchMode;
unsigned int m_ulRop2Mode;
double m_dPixelWidth;
double m_dPixelHeight;
TSvmWindow m_oWindow;
TSvmWindow m_oViewport;
TSvmPoint m_oCurPos;
// CSvmClip m_oClip;
unsigned int m_unArcDirection;
};
}
#endif
......@@ -46,15 +46,23 @@ void ConvertFolder(CMetaFile &oMetaFile, std::wstring wsFolderPath, const int nT
{
oMetaFile.Close();
std::vector<std::wstring> vFiles = GetAllFilesInFolder(wsFolderPath, nType == c_lMetaEmf ? L"emf" : L"wmf");
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");
oMetaFile.ConvertToRaster(wsDstFilePath.c_str(), 4, 1000);
std::wstring wsDstFilePath = (wsFilePath.substr(0, wsFilePath.size() - 3)).append(L"bmp");
oMetaFile.ConvertToRaster(wsDstFilePath.c_str(), 1, 1000);
oMetaFile.Close();
}
......@@ -68,7 +76,7 @@ void main()
oFonts.Initialize();
CMetaFile oMetaFile(&oFonts);
ConvertFolder(oMetaFile, L"D://Test Files//", c_lMetaEmf);
ConvertFolder(oMetaFile, L"D://test//_svm//", c_lMetaSvm);
//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
//_CrtDumpMemoryLeaks();
......
......@@ -198,6 +198,7 @@ namespace MetaFile
}
}
//---------------------------------------------------------------------------------------------------------------
CWmfDC::CWmfDC()
{
m_pBrush = &m_oDefaultBrush;
......
......@@ -22,6 +22,7 @@ namespace MetaFile
CWmfDC* SaveDC();
CWmfDC* RestoreDC();
CWmfDC* GetDC();
void RegisterObject(CWmfObjectBase* pObject);
void SelectObject(unsigned short ushIndex);
void SelectPalette(unsigned short ushIndex);
......
#pragma once
#ifdef _DEBUG
#pragma comment(lib, "../../Qt_build/graphics/project/debug/graphics.lib")
#else
#pragma comment(lib, "../../Qt_build/graphics/project/release/graphics.lib")
#endif
//#ifdef _DEBUG
//#pragma comment(lib, "../../Qt_build/graphics/project/debug/graphics.lib")
//#else
//#pragma comment(lib, "../../Qt_build/graphics/project/release/graphics.lib")
//#endif
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