mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
StarView Metafile по новому ..
git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62703 954022d7-b5bf-4e40-9824-e11837661b57
This commit is contained in:
committed by
Alexander Trofimov
parent
7641665fc7
commit
a5188a04fc
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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
|
||||
{
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#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);
|
||||
//------------------------------------------------------
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> 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();
|
||||
}
|
||||
|
||||
// <20><><EFBFBD> <20><> Wmf, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD> Emf
|
||||
m_oWmfFile.Close();
|
||||
|
||||
m_oEmfFile.OpenFromFile(wsFilePath);
|
||||
m_oEmfFile.Scan();
|
||||
|
||||
if (!m_oEmfFile.CheckError())
|
||||
// <20><><EFBFBD> <20><> Wmf
|
||||
if (m_oEmfFile.OpenFromFile(wsFilePath) == true)
|
||||
{
|
||||
m_lType = c_lMetaEmf;
|
||||
return true;
|
||||
}
|
||||
m_oEmfFile.Scan();
|
||||
|
||||
if (!m_oEmfFile.CheckError())
|
||||
{
|
||||
m_lType = c_lMetaEmf;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_oEmfFile.Close();
|
||||
}
|
||||
// <20><><EFBFBD> <20><> 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;
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> )
|
||||
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>
|
||||
663
DesktopEditor/raster/Metafile/StarView/SPEC
Normal file
663
DesktopEditor/raster/Metafile/StarView/SPEC
Normal file
@ -0,0 +1,663 @@
|
||||
StarView Metafile
|
||||
|
||||
Specification
|
||||
|
||||
Inge Wallin
|
||||
Pierre Ducroquet
|
||||
|
||||
|
||||
1. Introduction
|
||||
===============
|
||||
|
||||
This file describes the format of a StarView Metafile, SVM, the vector
|
||||
file format that is used by Star Office, OpenOffice.org, and
|
||||
LibreOffice to create object replacement images.
|
||||
|
||||
As far as we know, there is no formal specification of this format.
|
||||
This documentation has been created by reading the source code of
|
||||
LibreOffice, in the vcl subdirectory. The most important files are:
|
||||
|
||||
vcl/inc/vcl/gdimtf.hxx
|
||||
vcl/inc/vcl/metaact.hxx
|
||||
vcl/source/gdimtf.cxx
|
||||
vcl/source/metaact.cxx
|
||||
|
||||
The format of this document is modeled after the documentations of
|
||||
Windows MetaFile ([MS-WMF].pdf) and the Extended MetaFile
|
||||
([MS-EMF].pdf) from Microsoft.
|
||||
|
||||
|
||||
1.1 Glossary
|
||||
------------
|
||||
FIXME
|
||||
|
||||
|
||||
1.2 Structure Overview
|
||||
----------------------
|
||||
|
||||
An SVM file always starts with a signature of 6 bytes that identifies
|
||||
the file as an SVM. This signature is always the string "VCLMTF"
|
||||
(excluding the quotes).
|
||||
|
||||
Second, there is a header object describing the rest of the file.
|
||||
|
||||
Third, the header is followed by a number of actions as specified in
|
||||
the header. Each action or object, including the header, starts with
|
||||
a VersionCompat object that specifies the version and size of the
|
||||
action or object in question. The size in the VersionCompat object is
|
||||
*excluding* the VersionCompat itself.
|
||||
|
||||
|
||||
2. Structures
|
||||
=============
|
||||
|
||||
This section specifies the structures used in a StarView
|
||||
Metafile. This includes:
|
||||
|
||||
* enumerations of SVM constants: enums and flags
|
||||
|
||||
* definitions of SVM objects, i.e. primitive data types and
|
||||
composite structs and objects
|
||||
|
||||
* specifications of SVM actions.
|
||||
|
||||
|
||||
2.1 SVM Constants
|
||||
-----------------
|
||||
|
||||
Constants come in two different forms: enumerations and flags.
|
||||
|
||||
|
||||
2.1.1 SVM Enumerations
|
||||
- - - - - - - - - - - -
|
||||
|
||||
The following enumerations should be used in programs that handle SVM
|
||||
files.
|
||||
|
||||
|
||||
2.1.1.1 ActionType Enumeration
|
||||
|
||||
The ActionType Enumeration defines the type of actions that can be
|
||||
used in an SVM file.
|
||||
|
||||
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_COMMENT_ACTION = 512
|
||||
};
|
||||
|
||||
|
||||
2.1.1.2 Mtf Enumeration
|
||||
|
||||
The Mtf Enumeration defines ... FIXME
|
||||
|
||||
enum MtfType {
|
||||
MTF_CONVERSION_NONE = 0,
|
||||
MTF_CONVERSION_1BIT_THRESHOLD = 1,
|
||||
MTF_CONVERSION_8BIT_GREYS = 2
|
||||
};
|
||||
|
||||
|
||||
2.1.1.3 LineStyle Enumeration
|
||||
|
||||
enum LineStyle
|
||||
{
|
||||
LINE_NONE = 0,
|
||||
LINE_SOLID = 1,
|
||||
LINE_DASH = 2,
|
||||
};
|
||||
|
||||
|
||||
2.1.1.4 ... Enumeration
|
||||
FIXME
|
||||
|
||||
|
||||
2.1.2 SVM Flags
|
||||
- - - - - - - -
|
||||
|
||||
A variable can only containing one value from an SVM enumeration at
|
||||
the same time. In contrast, a variable containing SVN flags can
|
||||
combine as many values from the respective definition of flags as the
|
||||
enumeration of the flag itself.
|
||||
|
||||
|
||||
2.1.2.1 Mirror Flags
|
||||
|
||||
MTF_MIRROR_NONE 0x00000000
|
||||
MTF_MIRROR_HORZ 0x00000001
|
||||
MTF_MIRROR_VERT 0x00000002
|
||||
|
||||
FIXME: Check the details here.
|
||||
MTF_MIRROR_NONE The picture is not mirrored in any direction.
|
||||
|
||||
MTF_MIRROR_HORZ The picture should be drawn mirrored horizontally,
|
||||
i.e. mirrored in the center line of the picture
|
||||
parallel to the Y axis.
|
||||
|
||||
MTF_MIRROR_VERT The picture should be drawn mirrored vertically,
|
||||
i.e. mirrored in the center line of the picture
|
||||
parallel to the X axis.
|
||||
|
||||
In all of the cases above, the space occupied by the picture is the
|
||||
same.
|
||||
|
||||
|
||||
2.2 SVM Objects
|
||||
---------------
|
||||
|
||||
This section specifies the objects used in SVM files.
|
||||
|
||||
|
||||
2.2.1 Primitive Data Types
|
||||
- - - - - - - - - - - - - -
|
||||
|
||||
The following primitive data types are used in the objects or actions.
|
||||
|
||||
uint8 an unsigned 8 bit integer, taking up 1 byte in the file.
|
||||
int8 a signed 8 bit integer, taking up 1 byte in the file.
|
||||
uint16 an unsigned 16 bit integer, taking up 2 bytes in the file.
|
||||
int16 a signed 16 bit integer, taking up 2 bytes in the file.
|
||||
uint32 an unsigned 32 bit integer, taking up 4 bytes in the file.
|
||||
int32 a signed 32 bit integer, taking up 4 bytes in the file.
|
||||
bool an unsigned 8 bit value, taking up 1 byte in the file
|
||||
|
||||
Floating point values are not used in SVM.
|
||||
|
||||
|
||||
2.2.1 Basic Objects
|
||||
- - - - - - - - - -
|
||||
|
||||
These object types are mostly used as primitives in the larger and
|
||||
more complex object types and actions.
|
||||
|
||||
|
||||
2.2.1.1 VersionCompat Object
|
||||
|
||||
The VersionCompat object is always the first object of any bigger
|
||||
object and any action. This object describes which version the object
|
||||
or action has.
|
||||
|
||||
struct VersionCompat {
|
||||
uint16 version;
|
||||
uint32 length;
|
||||
}
|
||||
|
||||
version defines the version of the object. Depending on the
|
||||
version, the object will have a different number of
|
||||
components, thus changing the parser behaviour.
|
||||
|
||||
length defines the length of the object, excluding the
|
||||
VersionCompat object.
|
||||
|
||||
|
||||
2.2.1.2 Point
|
||||
|
||||
struct Point {
|
||||
uint32 x;
|
||||
uint32 y;
|
||||
}
|
||||
|
||||
|
||||
2.2.1.3 Polygon
|
||||
|
||||
struct Polygon {
|
||||
uint16 nPoints;
|
||||
Point points[nPoints];
|
||||
}
|
||||
|
||||
|
||||
2.2.1.4 PolyPolygon
|
||||
|
||||
struct PolyPolygon {
|
||||
uint16 nPolygons;
|
||||
Polygon polygons[nPolygons];
|
||||
}
|
||||
|
||||
|
||||
2.2.1.5 String
|
||||
|
||||
struct String {
|
||||
uint16 size;
|
||||
char data[size];
|
||||
}
|
||||
|
||||
A string object is built in a Pascal style, not a C style. There is
|
||||
no trailing \0 at the end of the string.
|
||||
|
||||
|
||||
2.2.1.6 Fraction
|
||||
|
||||
struct Fraction {
|
||||
uint32 numerator;
|
||||
unit32 denominator;
|
||||
}
|
||||
|
||||
The value of a Fraction is numerator/denominator.
|
||||
|
||||
|
||||
2.2.2 Header Object
|
||||
- - - - - - - - - -
|
||||
|
||||
The header object is a special object in an SVM. It is always the
|
||||
first object in the file. There is only one header object.
|
||||
|
||||
VersionCompat versionCompat
|
||||
uint32 compressionMode
|
||||
MapMode mapMode
|
||||
uint32 width
|
||||
uint32 height
|
||||
uint32 actionCount
|
||||
|
||||
versionCompat Version and size of the header record, excluding the
|
||||
VersionCompat object.
|
||||
|
||||
compressionMode ... FIXME
|
||||
|
||||
mapMode Default MapMode for the file. FIXME: Check if true
|
||||
|
||||
width Width of the picture in logical coordinates.
|
||||
|
||||
height Height of the picture in logical coordinates.
|
||||
|
||||
actionCount Number of Actions in the file.
|
||||
|
||||
|
||||
2.2.3 Graphics Objects
|
||||
- - - - - - - - - - - -
|
||||
|
||||
The SVM Graphics Objects specify parameters for graphics output. A
|
||||
particular graphics object becomes part of the drawing context when it
|
||||
is selected by an appropriate object record, and it is reused in
|
||||
subsequent graphics operations until a different object is selected.
|
||||
|
||||
|
||||
2.2.3.1 MapMode
|
||||
|
||||
This object describes some properties of the current drawing.
|
||||
|
||||
VersionCompat version
|
||||
uint16 unit
|
||||
Point origin
|
||||
Fraction scaleX
|
||||
Fraction scaleY
|
||||
bool isSimple
|
||||
|
||||
....FIXME: how do they alter the rendering context ?
|
||||
.... Can the scale, the origin change ?
|
||||
.... Find the values for the unit...
|
||||
|
||||
|
||||
2.2.3.2 Font
|
||||
|
||||
This object describes the properties of a font face to be used when rendering text.
|
||||
|
||||
VersionCompat version
|
||||
String family
|
||||
String style
|
||||
uint32 fontWidth
|
||||
uint32 fontHeight
|
||||
uint16 charset
|
||||
uint16 family
|
||||
uint16 pitch
|
||||
uint16 weight
|
||||
uint16 underline
|
||||
uint16 strikeout
|
||||
uint16 italic
|
||||
uint16 language
|
||||
uint16 width
|
||||
uint16 orientation
|
||||
bool wordline
|
||||
bool outline
|
||||
bool shadow
|
||||
int8 kerning
|
||||
If version is greater than 1:
|
||||
int8 relief
|
||||
uint16 language
|
||||
bool vertical
|
||||
uint16 emphasis
|
||||
If version is greater than 2:
|
||||
uint16 overline
|
||||
|
||||
version Version and size of the font record, excluding the
|
||||
VersionCompat object.
|
||||
|
||||
FIXME: Describe the following parts in detail
|
||||
family
|
||||
style
|
||||
fontWidth
|
||||
fontHeight
|
||||
charset
|
||||
family
|
||||
pitch
|
||||
weight
|
||||
underline
|
||||
strikeout
|
||||
italic
|
||||
language
|
||||
width
|
||||
orientation
|
||||
wordline
|
||||
outline
|
||||
shadow
|
||||
kerning
|
||||
If version is greater than 1:
|
||||
relief
|
||||
language
|
||||
vertical
|
||||
emphasis
|
||||
If version is greater than 2:
|
||||
overline
|
||||
|
||||
|
||||
|
||||
2.2.4 Structure Objects
|
||||
- - - - - - - - - - - -
|
||||
|
||||
The SVM Structure Objects specify data structures that are embedded in
|
||||
SVM objects and actions. Structure objects, unlike graphics objects,
|
||||
are not explicitly created or deleted; they are components of more
|
||||
complex structures.
|
||||
|
||||
|
||||
2.2.4.1 Color
|
||||
|
||||
FIXME
|
||||
|
||||
|
||||
2.2.4.2 PenInformations
|
||||
|
||||
This object describes the pen properties for drawing lines. Its
|
||||
contents depends on its version.
|
||||
|
||||
For all values of version:
|
||||
VersionCompat version
|
||||
uint16 lineStyle
|
||||
uint32 lineWidth
|
||||
If version is greater than 1:
|
||||
uint16 dashCount
|
||||
uint32 dashLength
|
||||
uint16 dotCount
|
||||
uint32 dotLength
|
||||
uint32 distance
|
||||
If version is greater than 2:
|
||||
uint16 lineJoin
|
||||
|
||||
lineStyle describes the line style of the pen. It can take any
|
||||
value of the LineStyle enumeration.
|
||||
|
||||
lineWidth width of the pen in <unit> (FIXME)
|
||||
|
||||
....FIXME: how to interpret the next fields values ?
|
||||
|
||||
|
||||
2.3 SVM Actions
|
||||
---------------
|
||||
|
||||
The action type is specified using a uint16 at the beginning of each
|
||||
action following the file header. Every action except the special
|
||||
META_NULL_ACTION begins with a VersionCompat object.
|
||||
|
||||
|
||||
2.3.1 Control Action Types
|
||||
- - - - - - - - - - - - - -
|
||||
|
||||
2.3.1.1 META_NULL_ACTION (0)
|
||||
|
||||
This action should never occur, ever.
|
||||
It contains a uint16 that is never used.
|
||||
|
||||
|
||||
2.3.1.2 META_COMMENT_ACTION (512)
|
||||
|
||||
A comment action has no effect on the rendering.
|
||||
|
||||
string comment
|
||||
uint32 value
|
||||
string comment2
|
||||
|
||||
|
||||
comment The comment text
|
||||
|
||||
value ... FIXME
|
||||
|
||||
comment2 ... FIXME
|
||||
|
||||
|
||||
2.3.2 State Action Types
|
||||
- - - - - - - - - - - - -
|
||||
|
||||
These actions change the state of the drawing context.
|
||||
|
||||
|
||||
2.3.2.1 META_LINECOLOR_ACTION (132)
|
||||
|
||||
A line color sets the pen color in the drawing context.
|
||||
|
||||
uint32 colorData
|
||||
bool doSet
|
||||
|
||||
colorData The color of the pen, in RGB format
|
||||
(... QColor::fromRgb format)
|
||||
|
||||
doSet Should the color be applied (true), or should the pen
|
||||
be hidden (false)
|
||||
|
||||
|
||||
2.3.2.2 META_FILLCOLOR_ACTION (133)
|
||||
|
||||
A fill color sets the brush color in the current context.
|
||||
It contains the following parts
|
||||
uint32 colorData
|
||||
bool isSet
|
||||
|
||||
colorData The color of the brush, in RGB format
|
||||
(... QColor::fromRgb format)
|
||||
|
||||
isSet Specifies wether the color should be be applied
|
||||
(true), or if the brush should be hidden (false)
|
||||
|
||||
|
||||
2.3.2.3 META_MAPMODE_ACTION (137)
|
||||
|
||||
This action loads a new MapMode object into the drawing context.
|
||||
|
||||
MapMode mapMode
|
||||
|
||||
|
||||
2.3.2.4 META_FONT_ACTION (138)
|
||||
|
||||
This action sets the current font in the graphics context.
|
||||
|
||||
Font font
|
||||
|
||||
font The new font that will be used when writing text.
|
||||
|
||||
|
||||
2.3.2.5 META_TEXTLANGUAGE_ACTION (150)
|
||||
|
||||
This action sets the current text language in the graphics context.
|
||||
|
||||
uint16 languageType
|
||||
|
||||
languageType It is a decimal code that specifies the language.
|
||||
It is described in i18npool/inc/i18npool/lang.h
|
||||
FIXME: Add these language codes to the enums in 2.1.1
|
||||
|
||||
|
||||
2.3.3 Drawing Action Types
|
||||
- - - - - - - - - - - - - -
|
||||
|
||||
These actions all cause some form of output to the picture. The
|
||||
operations described by these actions are influenced by the current
|
||||
drawing context.
|
||||
|
||||
|
||||
2.3.3.1 META_POLYLINE_ACTION (109)
|
||||
|
||||
A polyline action draws a polygon without filling it.
|
||||
|
||||
It contains the following parts
|
||||
Polygon polygon
|
||||
If the version of the action is greater than 1:
|
||||
PenInformations penInfos
|
||||
If the version of the action is greater than 2:
|
||||
bool polygonFlags
|
||||
If polygonFlags is true:
|
||||
VersionCompat flagsVersionCompat
|
||||
Polygon polygon (replaces the previous polygon)
|
||||
bool polygonFlagsEnabled
|
||||
If polygonFlagsEnabled
|
||||
....... FIXME!
|
||||
|
||||
polygon The polygon to draw
|
||||
|
||||
penInfos The pen style to apply
|
||||
|
||||
polygonFlags Indicate the presence of extra polygon informations
|
||||
....... FIXME: next part is complicated...
|
||||
|
||||
|
||||
2.3.3.2 META_POLYGON_ACTION (110)
|
||||
|
||||
A polygon action draws a polygon and filling it.
|
||||
|
||||
// FIXME: Check if the following is true. Right now it is just copied
|
||||
// from META_POLYLINE_ACTION
|
||||
Polygon polygon
|
||||
If the version of the action is greater than 1:
|
||||
PenInformations penInfos
|
||||
If the version of the action is greater than 2:
|
||||
bool polygonFlags
|
||||
If polygonFlags is true:
|
||||
VersionCompat flagsVersionCompat
|
||||
Polygon polygon (replaces the previous polygon)
|
||||
bool polygonFlagsEnabled
|
||||
If polygonFlagsEnabled
|
||||
....... FIXME!
|
||||
|
||||
polygon The polygon to draw
|
||||
|
||||
penInfos The pen style to apply
|
||||
|
||||
polygonFlags Indicate the presence of extra polygon informations
|
||||
....... FIXME: next part is complicated...
|
||||
|
||||
|
||||
2.3.3.3 META_POLYPOLYGON_ACTION (111)
|
||||
|
||||
A polypolygon action draws a group of polygons.
|
||||
|
||||
It contains the following parts
|
||||
PolyPolygon polygons
|
||||
If the version of the action is greater than 1:
|
||||
uint16 numberOfComplexPolygons
|
||||
For each complexPolygon :
|
||||
uint16 complexPolygonIndex
|
||||
Polygon complexPolygon
|
||||
|
||||
The complexPolygonIndex is used to replace a polygon from the polygons list.
|
||||
|
||||
|
||||
2.3.4 Unsorted Action Types
|
||||
- - - - - - - - - - - - - -
|
||||
|
||||
These action types have so far not being sorted into any other type.
|
||||
|
||||
META_PIXEL_ACTION
|
||||
META_POINT_ACTION
|
||||
META_LINE_ACTION
|
||||
META_RECT_ACTION
|
||||
META_ROUNDRECT_ACTION
|
||||
META_ELLIPSE_ACTION
|
||||
META_ARC_ACTION
|
||||
META_PIE_ACTION
|
||||
META_CHORD_ACTION
|
||||
META_POLYGON_ACTION
|
||||
META_TEXT_ACTION
|
||||
META_TEXTARRAY_ACTION
|
||||
META_STRETCHTEXT_ACTION
|
||||
META_TEXTRECT_ACTION
|
||||
META_BMP_ACTION
|
||||
META_BMPSCALE_ACTION
|
||||
META_BMPSCALEPART_ACTION
|
||||
META_BMPEX_ACTION
|
||||
META_BMPEXSCALE_ACTION
|
||||
META_BMPEXSCALEPART_ACTION
|
||||
META_MASK_ACTION
|
||||
META_MASKSCALE_ACTION
|
||||
META_MASKSCALEPART_ACTION
|
||||
META_GRADIENT_ACTION
|
||||
META_HATCH_ACTION
|
||||
META_WALLPAPER_ACTION
|
||||
META_CLIPREGION_ACTION
|
||||
META_ISECTRECTCLIPREGION_ACTION
|
||||
META_ISECTREGIONCLIPREGION_ACTION
|
||||
META_MOVECLIPREGION_ACTION
|
||||
META_TEXTCOLOR_ACTION
|
||||
META_TEXTFILLCOLOR_ACTION
|
||||
META_TEXTALIGN_ACTION
|
||||
META_FONT_ACTION
|
||||
META_PUSH_ACTION
|
||||
META_POP_ACTION
|
||||
META_RASTEROP_ACTION
|
||||
META_TRANSPARENT_ACTION
|
||||
META_EPS_ACTION
|
||||
META_REFPOINT_ACTION
|
||||
META_TEXTLINECOLOR_ACTION
|
||||
META_TEXTLINE_ACTION
|
||||
META_FLOATTRANSPARENT_ACTION
|
||||
META_GRADIENTEX_ACTION
|
||||
META_LAYOUTMODE_ACTION
|
||||
META_OVERLINECOLOR_ACTION
|
||||
|
||||
102
DesktopEditor/raster/Metafile/StarView/SvmAbstractPlayer.h
Normal file
102
DesktopEditor/raster/Metafile/StarView/SvmAbstractPlayer.h
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
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
|
||||
|
||||
108
DesktopEditor/raster/Metafile/StarView/SvmEnums.h
Normal file
108
DesktopEditor/raster/Metafile/StarView/SvmEnums.h
Normal file
@ -0,0 +1,108 @@
|
||||
#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
|
||||
|
||||
454
DesktopEditor/raster/Metafile/StarView/SvmFile.cpp
Normal file
454
DesktopEditor/raster/Metafile/StarView/SvmFile.cpp
Normal file
@ -0,0 +1,454 @@
|
||||
|
||||
// Own
|
||||
#include "SvmFile.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../Common/MetaFileTypes.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include <iostream>
|
||||
#endif
|
||||
// MetaFile
|
||||
#include "SvmEnums.h"
|
||||
#include "SvmObjects.h"
|
||||
|
||||
// 0 - No debug
|
||||
// 1 - Print a lot of debug info
|
||||
// 2 - Just print all the records instead of parsing them
|
||||
#define DEBUG_CSvmParser 0
|
||||
|
||||
namespace MetaFile
|
||||
{
|
||||
|
||||
static const struct ActionNames
|
||||
{
|
||||
int actionNumber;
|
||||
std::wstring actionName;
|
||||
} actionNames[] =
|
||||
{
|
||||
{ META_NULL_ACTION, L"META_NULL_ACTION" },
|
||||
{ META_PIXEL_ACTION, L"META_PIXEL_ACTION" },
|
||||
{ META_POINT_ACTION, L"META_POINT_ACTION" },
|
||||
{ META_LINE_ACTION, L"META_LINE_ACTION" },
|
||||
{ META_RECT_ACTION, L"META_RECT_ACTION" },
|
||||
{ META_ROUNDRECT_ACTION, L"META_ROUNDRECT_ACTION" },
|
||||
{ META_ELLIPSE_ACTION, L"META_ELLIPSE_ACTION" },
|
||||
{ META_ARC_ACTION, L"META_ARC_ACTION" },
|
||||
{ META_PIE_ACTION, L"META_PIE_ACTION" },
|
||||
{ META_CHORD_ACTION, L"META_CHORD_ACTION" },
|
||||
{ META_POLYLINE_ACTION, L"META_POLYLINE_ACTION" },
|
||||
{ META_POLYGON_ACTION, L"META_POLYGON_ACTION" },
|
||||
{ META_POLYPOLYGON_ACTION, L"META_POLYPOLYGON_ACTION" },
|
||||
{ META_TEXT_ACTION, L"META_TEXT_ACTION" },
|
||||
{ META_TEXTARRAY_ACTION, L"META_TEXTARRAY_ACTION" },
|
||||
{ META_STRETCHTEXT_ACTION, L"META_STRETCHTEXT_ACTION" },
|
||||
{ META_TEXTRECT_ACTION, L"META_TEXTRECT_ACTION" },
|
||||
{ META_BMP_ACTION, L"META_BMP_ACTION" },
|
||||
{ META_BMPSCALE_ACTION, L"META_BMPSCALE_ACTION" },
|
||||
{ META_BMPSCALEPART_ACTION, L"META_BMPSCALEPART_ACTION" },
|
||||
{ META_BMPEX_ACTION, L"META_BMPEX_ACTION" },
|
||||
{ META_BMPEXSCALE_ACTION, L"META_BMPEXSCALE_ACTION" },
|
||||
{ META_BMPEXSCALEPART_ACTION, L"META_BMPEXSCALEPART_ACTION" },
|
||||
{ META_MASK_ACTION, L"META_MASK_ACTION" },
|
||||
{ META_MASKSCALE_ACTION, L"META_MASKSCALE_ACTION" },
|
||||
{ META_MASKSCALEPART_ACTION, L"META_MASKSCALEPART_ACTION" },
|
||||
{ META_GRADIENT_ACTION, L"META_GRADIENT_ACTION" },
|
||||
{ META_HATCH_ACTION, L"META_HATCH_ACTION" },
|
||||
{ META_WALLPAPER_ACTION, L"META_WALLPAPER_ACTION" },
|
||||
{ META_CLIPREGION_ACTION, L"META_CLIPREGION_ACTION" },
|
||||
{ META_ISECTRECTCLIPREGION_ACTION, L"META_ISECTRECTCLIPREGION_ACTION" },
|
||||
{ META_ISECTREGIONCLIPREGION_ACTION, L"META_ISECTREGIONCLIPREGION_ACTION" },
|
||||
{ META_MOVECLIPREGION_ACTION, L"META_MOVECLIPREGION_ACTION" },
|
||||
{ META_LINECOLOR_ACTION, L"META_LINECOLOR_ACTION" },
|
||||
{ META_FILLCOLOR_ACTION, L"META_FILLCOLOR_ACTION" },
|
||||
{ META_TEXTCOLOR_ACTION, L"META_TEXTCOLOR_ACTION" },
|
||||
{ META_TEXTFILLCOLOR_ACTION, L"META_TEXTFILLCOLOR_ACTION" },
|
||||
{ META_TEXTALIGN_ACTION, L"META_TEXTALIGN_ACTION" },
|
||||
{ META_MAPMODE_ACTION, L"META_MAPMODE_ACTION" },
|
||||
{ META_FONT_ACTION, L"META_FONT_ACTION" },
|
||||
{ META_PUSH_ACTION, L"META_PUSH_ACTION" },
|
||||
{ META_POP_ACTION, L"META_POP_ACTION" },
|
||||
{ META_RASTEROP_ACTION, L"META_RASTEROP_ACTION" },
|
||||
{ META_TRANSPARENT_ACTION, L"META_TRANSPARENT_ACTION" },
|
||||
{ META_EPS_ACTION, L"META_EPS_ACTION" },
|
||||
{ META_REFPOINT_ACTION, L"META_REFPOINT_ACTION" },
|
||||
{ META_TEXTLINECOLOR_ACTION, L"META_TEXTLINECOLOR_ACTION" },
|
||||
{ META_TEXTLINE_ACTION, L"META_TEXTLINE_ACTION" },
|
||||
{ META_FLOATTRANSPARENT_ACTION, L"META_FLOATTRANSPARENT_ACTION" },
|
||||
{ META_GRADIENTEX_ACTION, L"META_GRADIENTEX_ACTION" },
|
||||
{ META_LAYOUTMODE_ACTION, L"META_LAYOUTMODE_ACTION" },
|
||||
{ META_TEXTLANGUAGE_ACTION, L"META_TEXTLANGUAGE_ACTION" },
|
||||
{ META_OVERLINECOLOR_ACTION, L"META_OVERLINECOLOR_ACTION" },
|
||||
{ META_RENDERGRAPHIC_ACTION, L"META_RENDERGRAPHIC_ACTION" },
|
||||
{ META_COMMENT_ACTION, L"META_COMMENT_ACTION" }
|
||||
};
|
||||
|
||||
void CSvmFile::PlayMetaFile()
|
||||
{
|
||||
m_oStream.SeekToStart();
|
||||
BYTE* startPosBuffer = m_oStream.GetCurPtr();
|
||||
|
||||
// Check the signature "VCLMTF"
|
||||
std::string start = std::string((char*)m_oStream.GetCurPtr(), 6);
|
||||
|
||||
if (start != "VCLMTF")
|
||||
return;
|
||||
|
||||
|
||||
// Start reading from the stream: read past the signature and get the header.
|
||||
soakBytes(m_oStream, 6);
|
||||
Read_SVM_HEADER();
|
||||
|
||||
//kDebug(31000) << "================ SVM HEADER ================";
|
||||
//kDebug(31000) << "version, length:" << header.versionCompat.version << header.versionCompat.length;
|
||||
//kDebug(31000) << "compressionMode:" << header.compressionMode;
|
||||
//kDebug(31000) << "mapMode:" << "Origin" << header.mapMode.origin
|
||||
//<< "scaleX"
|
||||
//<< header.mapMode.scaleX.numerator << header.mapMode.scaleX.numerator
|
||||
//<< (qreal(header.mapMode.scaleX.numerator) / header.mapMode.scaleX.numerator)
|
||||
//<< "scaleY"
|
||||
//<< header.mapMode.scaleY.numerator << header.mapMode.scaleY.numerator
|
||||
//<< (qreal(header.mapMode.scaleX.numerator) / header.mapMode.scaleX.numerator);
|
||||
//kDebug(31000) << "size:" << header.width << header.height;
|
||||
//kDebug(31000) << "actionCount:" << header.actionCount;
|
||||
//kDebug(31000) << "================ SVM HEADER ================";
|
||||
|
||||
if (m_pOutput)
|
||||
m_pOutput->Begin();
|
||||
|
||||
#if DEBUG_CSvmParser
|
||||
{
|
||||
QPolygon polygon;
|
||||
polygon << QPoint(0, 0);
|
||||
polygon << QPoint(header.width, header.height);
|
||||
mBackend->polyLine(mContext, polygon);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Parse all actions and call the appropriate backend callback for
|
||||
// the graphics drawing actions. The context actions will
|
||||
// manipulate the graphics context, which is maintained here.
|
||||
for (unsigned int action = 0; action < m_oHeader.actionCount; ++action)
|
||||
{
|
||||
unsigned short actionType;
|
||||
unsigned short version;
|
||||
unsigned int totalSize;
|
||||
|
||||
m_oStream >> actionType;
|
||||
|
||||
m_oStream >> version;
|
||||
m_oStream >> totalSize;
|
||||
|
||||
m_ulRecordSize = totalSize;// - 8;
|
||||
|
||||
int start_node_pos = m_oStream.GetCurPtr() - startPosBuffer;
|
||||
// Debug
|
||||
#if _DEBUG
|
||||
{
|
||||
std::wstring name;
|
||||
if (actionType == 0)
|
||||
name = actionNames[0].actionName;
|
||||
else if (actionType == 512)
|
||||
name = L"META_COMMENT_ACTION";
|
||||
else if (100 <= actionType && actionType <= META_LAST_ACTION)
|
||||
name = actionNames[actionType - 99].actionName;
|
||||
else
|
||||
name = L"(out of bounds)";
|
||||
|
||||
std::wcout << name << L"\t(" << actionType << L") " << L"\tversion = " << version << L"\t; totalSize = " << totalSize << L"\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
// Parse all actions.
|
||||
switch (actionType)
|
||||
{
|
||||
case META_RECT_ACTION: Read_META_RECTANGLE(); break;
|
||||
case META_POLYLINE_ACTION:
|
||||
case META_POLYGON_ACTION:
|
||||
{
|
||||
unsigned int size = Read_META_POLYGON();
|
||||
// FIXME: Version 2: Lineinfo, Version 3: polyflags
|
||||
if (version > 1)
|
||||
soakBytes(m_oStream, totalSize - 2 - 4 * 2 * size); //2 points * 4 byte * size polygon
|
||||
|
||||
}break;
|
||||
case META_POLYPOLYGON_ACTION: Read_META_POLYPOLYGON(version); break;
|
||||
|
||||
case META_TEXT_ACTION:
|
||||
case META_TEXTARRAY_ACTION: Read_META_TEXT_A(); break;
|
||||
case META_LINECOLOR_ACTION: Read_META_SETLINECOLOR(); break;
|
||||
case META_FILLCOLOR_ACTION: Read_META_SETFILLCOLOR(); break;
|
||||
case META_TEXTCOLOR_ACTION: Read_META_SETTEXTCOLOR(); break;
|
||||
case META_MAPMODE_ACTION: Read_META_SETMAPMODE(); break;
|
||||
case META_FONT_ACTION: Read_META_CREATEFONT(); break;
|
||||
case META_PUSH_ACTION:
|
||||
{
|
||||
////kDebug(31000) << "Push action : " << totalSize;
|
||||
unsigned short pushValue;
|
||||
m_oStream >> pushValue;
|
||||
////kDebug(31000) << "Push value : " << pushValue;
|
||||
}break;
|
||||
case META_POP_ACTION:
|
||||
//{
|
||||
// //kDebug(31000) << "Pop action : " << totalSize;
|
||||
// /*unsigned short pushValue;
|
||||
// m_oStream >> pushValue;
|
||||
// //kDebug(31000) << "Push value : " << pushValue;*/
|
||||
//}break;
|
||||
case META_STRETCHTEXT_ACTION:
|
||||
case META_TEXTRECT_ACTION:
|
||||
case META_BMP_ACTION:
|
||||
case META_BMPSCALE_ACTION:
|
||||
case META_BMPSCALEPART_ACTION:
|
||||
case META_BMPEX_ACTION:
|
||||
case META_BMPEXSCALE_ACTION:
|
||||
case META_BMPEXSCALEPART_ACTION:
|
||||
case META_MASK_ACTION:
|
||||
case META_MASKSCALE_ACTION:
|
||||
case META_MASKSCALEPART_ACTION:
|
||||
case META_GRADIENT_ACTION:
|
||||
case META_HATCH_ACTION:
|
||||
case META_WALLPAPER_ACTION:
|
||||
case META_CLIPREGION_ACTION:
|
||||
case META_ISECTRECTCLIPREGION_ACTION:
|
||||
case META_ISECTREGIONCLIPREGION_ACTION:
|
||||
case META_MOVECLIPREGION_ACTION:
|
||||
case META_TEXTFILLCOLOR_ACTION:
|
||||
case META_TEXTALIGN_ACTION:
|
||||
case META_RASTEROP_ACTION:
|
||||
case META_TRANSPARENT_ACTION:
|
||||
case META_EPS_ACTION:
|
||||
case META_REFPOINT_ACTION:
|
||||
case META_TEXTLINECOLOR_ACTION:
|
||||
case META_TEXTLINE_ACTION:
|
||||
case META_FLOATTRANSPARENT_ACTION:
|
||||
case META_GRADIENTEX_ACTION:
|
||||
case META_LAYOUTMODE_ACTION:
|
||||
case META_TEXTLANGUAGE_ACTION:
|
||||
case META_OVERLINECOLOR_ACTION:
|
||||
case META_RENDERGRAPHIC_ACTION: //dumpAction(m_oStream, version, totalSize);
|
||||
case META_COMMENT_ACTION:
|
||||
case META_ROUNDRECT_ACTION:
|
||||
case META_ELLIPSE_ACTION:
|
||||
case META_ARC_ACTION:
|
||||
case META_PIE_ACTION:
|
||||
case META_CHORD_ACTION:
|
||||
case META_NULL_ACTION:
|
||||
case META_PIXEL_ACTION:
|
||||
case META_POINT_ACTION:
|
||||
case META_LINE_ACTION:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int cur_pos = m_oStream.GetCurPtr() - startPosBuffer;
|
||||
int need_skip = totalSize - (cur_pos - start_node_pos);
|
||||
m_oStream.Skip(need_skip);
|
||||
}
|
||||
if (m_pOutput)
|
||||
m_pOutput->End();
|
||||
}
|
||||
|
||||
|
||||
void CSvmFile::Read_META_RECTANGLE()
|
||||
{
|
||||
TSvmRect oBox;
|
||||
m_oStream >> oBox;
|
||||
{
|
||||
MoveTo(oBox.l, oBox.t);
|
||||
LineTo(oBox.r, oBox.t);
|
||||
LineTo(oBox.r, oBox.b);
|
||||
LineTo(oBox.l, oBox.b);
|
||||
}
|
||||
ClosePath();
|
||||
DrawPath(true, true);
|
||||
}
|
||||
void CSvmFile::Read_SVM_HEADER()
|
||||
{
|
||||
m_oStream >> m_oHeader;
|
||||
}
|
||||
unsigned int CSvmFile::Read_META_POLYGON()
|
||||
{
|
||||
TSvmPolygon polygon;
|
||||
|
||||
m_oStream >> polygon;
|
||||
|
||||
if (polygon.count < 1) return 0;
|
||||
|
||||
MoveTo(polygon.points[0].x, polygon.points[0].y);
|
||||
|
||||
for (int i = 1; i < polygon.count; i++)
|
||||
{
|
||||
LineTo(polygon.points[i].x, polygon.points[i].y);
|
||||
}
|
||||
ClosePath();
|
||||
DrawPath(true, true);
|
||||
|
||||
return polygon.count;
|
||||
}
|
||||
|
||||
void CSvmFile::Read_META_POLYPOLYGON(int version)
|
||||
{
|
||||
std::vector<TSvmPolygon> polygons;
|
||||
|
||||
unsigned short ushNumberOfPolygons;
|
||||
m_oStream >> ushNumberOfPolygons;
|
||||
if (ushNumberOfPolygons <= 0)
|
||||
return;
|
||||
|
||||
for (unsigned short ushIndex = 0; ushIndex < ushNumberOfPolygons; ushIndex++)
|
||||
{
|
||||
TSvmPolygon poligon;
|
||||
|
||||
m_oStream >> poligon;
|
||||
polygons.push_back(poligon);
|
||||
}
|
||||
//todooo ??? <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ???
|
||||
|
||||
std::vector<TSvmPolygon> complexPolygons;
|
||||
if (version > 1)
|
||||
{
|
||||
unsigned short complexPolygonCount;
|
||||
m_oStream >> complexPolygonCount;
|
||||
|
||||
complexPolygons.resize(complexPolygonCount);
|
||||
|
||||
for (unsigned short i = 0; i < complexPolygonCount; i++)
|
||||
{
|
||||
unsigned short complexPolygonIndex;
|
||||
m_oStream >> complexPolygonIndex;
|
||||
|
||||
m_oStream >> complexPolygons[complexPolygonIndex];
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
for (unsigned short ushPolygonIndex = 0; ushPolygonIndex < ushNumberOfPolygons; ushPolygonIndex++)
|
||||
{
|
||||
unsigned short ushPointsCount = polygons[ushPolygonIndex].count;
|
||||
|
||||
if (ushPointsCount <= 0)
|
||||
continue;
|
||||
|
||||
MoveTo(polygons[ushPolygonIndex].points[0].x, polygons[ushPolygonIndex].points[0].y);
|
||||
for (int i = 1; i < ushPointsCount; i++)
|
||||
{
|
||||
LineTo(polygons[ushPolygonIndex].points[i].x, polygons[ushPolygonIndex].points[i].y);
|
||||
}
|
||||
ClosePath();
|
||||
}
|
||||
//for (unsigned short ushPolygonIndex = 0; ushPolygonIndex < ushNumberOfPolygons; ushPolygonIndex++)
|
||||
//{
|
||||
// unsigned short ushPointsCount = complexPolygons[ushPolygonIndex].count;
|
||||
|
||||
// if (ushPointsCount <= 0)
|
||||
// continue;
|
||||
|
||||
// MoveTo(complexPolygons[ushPolygonIndex].points[0].x, complexPolygons[ushPolygonIndex].points[0].y);
|
||||
// for (int i = 1; i < ushPointsCount; i++)
|
||||
// {
|
||||
// LineTo(complexPolygons[ushPolygonIndex].points[i].x, complexPolygons[ushPolygonIndex].points[i].y);
|
||||
// }
|
||||
// ClosePath();
|
||||
//}
|
||||
DrawPath(true, true);
|
||||
}
|
||||
|
||||
void CSvmFile::Read_META_SETMAPMODE()
|
||||
{
|
||||
MapMode mapMode;
|
||||
m_oStream >> mapMode;
|
||||
////kDebug(31000) << "mapMode:" << "Origin" << mContext.mapMode.origin
|
||||
// << "scaleX"
|
||||
// << mContext.mapMode.scaleX.numerator << mContext.mapMode.scaleX.numerator
|
||||
// << (qreal(mContext.mapMode.scaleX.numerator) / mContext.mapMode.scaleX.numerator)
|
||||
// << "scaleY"
|
||||
// << mContext.mapMode.scaleY.numerator << mContext.mapMode.scaleY.numerator
|
||||
// << (qreal(mContext.mapMode.scaleX.numerator) / mContext.mapMode.scaleX.numerator);
|
||||
|
||||
m_pDC->SetMapMode(mapMode);
|
||||
UpdateOutputDC();
|
||||
}
|
||||
void CSvmFile::Read_META_TEXT_A()
|
||||
{
|
||||
std::wstring sText;
|
||||
TSvmPoint startPoint;
|
||||
|
||||
m_oStream >> startPoint;
|
||||
parseString(m_oStream, sText);
|
||||
|
||||
DrawText(sText, sText.length(), startPoint.x, startPoint.y);
|
||||
}
|
||||
void CSvmFile::Read_META_SETTEXTCOLOR()
|
||||
{
|
||||
TSvmColor oColor; //??? 3 byte????
|
||||
m_oStream >> oColor;
|
||||
m_pDC->SetTextColor(oColor);
|
||||
UpdateOutputDC();
|
||||
}
|
||||
void CSvmFile::Read_META_SETFILLCOLOR()
|
||||
{
|
||||
bool doSet;
|
||||
TSvmColor oColor; //??? 3 byte????
|
||||
|
||||
m_oStream >> oColor;
|
||||
m_oStream >> doSet;
|
||||
|
||||
CSvmBrush* pBrush = new CSvmBrush();
|
||||
if (!pBrush)
|
||||
return SetError();
|
||||
|
||||
pBrush->BrushStyle = BS_NULL;
|
||||
if (doSet)
|
||||
{
|
||||
pBrush->Color = oColor;
|
||||
pBrush->BrushStyle = BS_SOLID;
|
||||
}
|
||||
m_oPlayer.RegisterObject((CSvmObjectBase*)pBrush);
|
||||
}
|
||||
|
||||
void CSvmFile::Read_META_SETLINECOLOR()
|
||||
{
|
||||
TSvmColor colorData;
|
||||
bool doSet;
|
||||
|
||||
m_oStream >> colorData;
|
||||
m_oStream >> doSet;
|
||||
|
||||
CSvmPen* pPen = new CSvmPen();
|
||||
if (!pPen)
|
||||
return SetError();
|
||||
|
||||
pPen->PenStyle = PS_NULL;
|
||||
if (doSet)
|
||||
{
|
||||
pPen->Color = colorData;
|
||||
pPen->PenStyle = PS_COSMETIC | PS_SOLID;
|
||||
}
|
||||
m_oPlayer.RegisterObject((CSvmObjectBase*)pPen);
|
||||
}
|
||||
void CSvmFile::Read_META_CREATEFONT()
|
||||
{
|
||||
CSvmFont* pFont = new CSvmFont();
|
||||
if (!pFont)
|
||||
return SetError();
|
||||
|
||||
m_oStream >> pFont;
|
||||
m_oPlayer.RegisterObject((CSvmObjectBase*)pFont);
|
||||
}
|
||||
|
||||
void CSvmFile::dumpAction(CDataStream &stream, unsigned short version, unsigned int totalSize)
|
||||
{
|
||||
//qDebug() << "Version: " << version;
|
||||
for (unsigned int i = 0; i < totalSize; ++i)
|
||||
{
|
||||
unsigned char temp;
|
||||
stream >> temp;
|
||||
//qDebug() << hex << i << temp << dec;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace MetaFile
|
||||
|
||||
523
DesktopEditor/raster/Metafile/StarView/SvmFile.h
Normal file
523
DesktopEditor/raster/Metafile/StarView/SvmFile.h
Normal file
@ -0,0 +1,523 @@
|
||||
/* This file is part of the Calligra project
|
||||
|
||||
Copyright 2011 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 SVMPARSER_H
|
||||
#define SVMPARSER_H
|
||||
|
||||
|
||||
#include "SvmPlayer.h"
|
||||
|
||||
#include "../Common/MetaFile.h"
|
||||
|
||||
namespace MetaFile
|
||||
{
|
||||
|
||||
|
||||
class CSvmFile : virtual public IMetaFileBase
|
||||
{
|
||||
public:
|
||||
CSvmFile() : m_oPlayer(this)
|
||||
{
|
||||
m_pDC = m_oPlayer.GetDC();
|
||||
};
|
||||
|
||||
~CSvmFile()
|
||||
{
|
||||
ClearFile();
|
||||
};
|
||||
|
||||
|
||||
void PlayMetaFile();
|
||||
void ClearFile()
|
||||
{
|
||||
m_oPlayer.Clear();
|
||||
m_pDC = m_oPlayer.GetDC();
|
||||
}
|
||||
TRect* GetBounds()
|
||||
{
|
||||
return &m_oHeader.boundRect;
|
||||
}
|
||||
TRect* GetDCBounds()
|
||||
{
|
||||
return &m_oHeader.boundRect;
|
||||
}
|
||||
double GetPixelHeight()
|
||||
{
|
||||
return m_pDC->GetPixelHeight();
|
||||
}
|
||||
double GetPixelWidth()
|
||||
{
|
||||
return m_pDC->GetPixelWidth();
|
||||
}
|
||||
int GetTextColor()
|
||||
{
|
||||
TSvmColor& oColor = m_pDC->GetTextColor();
|
||||
return METAFILE_RGBA(oColor.r, oColor.g, oColor.b);
|
||||
}
|
||||
IFont* GetFont()
|
||||
{
|
||||
CSvmFont* pFont = m_pDC->GetFont();
|
||||
if (!pFont)
|
||||
return NULL;
|
||||
|
||||
return (IFont*)pFont;
|
||||
}
|
||||
IBrush* GetBrush()
|
||||
{
|
||||
CSvmBrush* pBrush = m_pDC->GetBrush();
|
||||
if (!pBrush)
|
||||
return NULL;
|
||||
|
||||
return (IBrush*)pBrush;
|
||||
}
|
||||
IPen* GetPen()
|
||||
{
|
||||
CSvmPen* pPen = m_pDC->GetPen();
|
||||
if (!pPen)
|
||||
return NULL;
|
||||
|
||||
return (IPen*)pPen;
|
||||
}
|
||||
unsigned int GetTextAlign()
|
||||
{
|
||||
return m_pDC->GetTextAlign();
|
||||
}
|
||||
unsigned int GetTextBgMode()
|
||||
{
|
||||
return m_pDC->GetBgMode();
|
||||
}
|
||||
int GetTextBgColor()
|
||||
{
|
||||
TSvmColor& oColor = m_pDC->GetBgColor();
|
||||
return METAFILE_RGBA(oColor.r, oColor.g, oColor.b);
|
||||
}
|
||||
unsigned int GetFillMode()
|
||||
{
|
||||
return m_pDC->GetFillMode();
|
||||
}
|
||||
TPointD GetCurPos()
|
||||
{
|
||||
TSvmPoint oPoint = m_pDC->GetCurPos();
|
||||
TPointD oRes;
|
||||
TranslatePoint(oPoint.x, oPoint.y, oRes.x, oRes.y);
|
||||
return oRes;
|
||||
}
|
||||
TXForm* GetInverseTransform()
|
||||
{
|
||||
return m_pDC->GetInverseTransform();
|
||||
}
|
||||
TXForm* GetTransform()
|
||||
{
|
||||
return m_pDC->GetTransform();
|
||||
}
|
||||
unsigned int GetMiterLimit()
|
||||
{
|
||||
return m_pDC->GetMiterLimit();
|
||||
}
|
||||
unsigned int GetRop2Mode()
|
||||
{
|
||||
return m_pDC->GetRop2Mode();
|
||||
}
|
||||
IClip* GetClip()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
int GetCharSpace()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
private:
|
||||
void dumpAction(CDataStream &stream, unsigned short version, unsigned int totalSize);
|
||||
|
||||
|
||||
private:
|
||||
BYTE* m_pBufferData;
|
||||
CSvmDC* m_pDC;
|
||||
CSvmPlayer m_oPlayer;
|
||||
SvmHeader m_oHeader;
|
||||
unsigned int m_ulRecordSize;
|
||||
|
||||
friend class CSvmPlayer;
|
||||
|
||||
void Read_META_RECTANGLE();
|
||||
void Read_SVM_HEADER();
|
||||
unsigned int Read_META_POLYGON();
|
||||
void Read_META_POLYPOLYGON(int version);
|
||||
void Read_META_TEXT_A();
|
||||
void Read_META_SETMAPMODE();
|
||||
void Read_META_SETTEXTCOLOR();
|
||||
void Read_META_SETFILLCOLOR();
|
||||
void Read_META_SETLINECOLOR();
|
||||
void Read_META_CREATEFONT();
|
||||
void Read_META_UNKNOWN()
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_oStream.Skip(m_ulRecordSize);
|
||||
}
|
||||
void TranslatePoint(TEmfPointL& oPoint, double& dX, double& dY)
|
||||
{
|
||||
TranslatePoint(oPoint.x, oPoint.y, dX, dY);
|
||||
}
|
||||
void TranslatePoint(int nX, int nY, double& dX, double &dY)
|
||||
{
|
||||
TSvmWindow* pWindow = m_pDC->GetWindow();
|
||||
TSvmWindow* pViewport = m_pDC->GetViewport();
|
||||
|
||||
dX = (double)((double)(nX - pWindow->lX) * m_pDC->GetPixelWidth()) + pViewport->lX;
|
||||
dY = (double)((double)(nY - pWindow->lY) * m_pDC->GetPixelHeight()) + pViewport->lY;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
TRect* pBounds = GetDCBounds();
|
||||
double dT = pBounds->nTop;
|
||||
double dL = pBounds->nLeft;
|
||||
|
||||
TXForm* pInverse = GetInverseTransform();
|
||||
TXForm* pTransform = GetTransform();
|
||||
pTransform->Apply(dX, dY);
|
||||
dX -= dL;
|
||||
dY -= dT;
|
||||
pInverse->Apply(dX, dY);
|
||||
}
|
||||
|
||||
bool ReadImage(unsigned int offBmi, unsigned int cbBmi, unsigned int offBits, unsigned int cbBits, unsigned int ulSkip, BYTE** ppBgraBuffer, unsigned int* pulWidth, unsigned int* pulHeight)
|
||||
{
|
||||
int lHeaderOffset = offBmi - ulSkip;
|
||||
unsigned int ulHeaderSize = cbBmi;
|
||||
int lBitsOffset = offBits - offBmi - cbBmi;
|
||||
unsigned int ulBitsSize = cbBits;
|
||||
if (ulHeaderSize <= 0 || ulBitsSize <= 0 || lHeaderOffset < 0 || lBitsOffset < 0)
|
||||
{
|
||||
// TODO: <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BitBltRasterOperation
|
||||
if (lHeaderOffset > 0)
|
||||
m_oStream.Skip(lHeaderOffset);
|
||||
|
||||
m_oStream.Skip(ulHeaderSize);
|
||||
|
||||
if (lBitsOffset > 0)
|
||||
m_oStream.Skip(lBitsOffset);
|
||||
|
||||
m_oStream.Skip(ulBitsSize);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_oStream.Skip(lHeaderOffset);
|
||||
|
||||
BYTE* pHeaderBuffer = m_oStream.GetCurPtr();
|
||||
m_oStream.Skip(ulHeaderSize + lBitsOffset);
|
||||
BYTE* pBitsBuffer = m_oStream.GetCurPtr();
|
||||
m_oStream.Skip(ulBitsSize);
|
||||
|
||||
MetaFile::ReadImage(pHeaderBuffer, ulHeaderSize, pBitsBuffer, ulBitsSize, ppBgraBuffer, pulWidth, pulHeight);
|
||||
|
||||
return true;
|
||||
}
|
||||
void DrawImage(int nX, int nY, int nW, int nH, BYTE* pImageBuffer, unsigned int unImageW, unsigned int unImageH)
|
||||
{
|
||||
if (m_pOutput)
|
||||
{
|
||||
double dX, dY, dR, dB;
|
||||
TranslatePoint(nX, nY, dX, dY);
|
||||
TranslatePoint(nX + nW, nY + nH, dR, dB);
|
||||
m_pOutput->DrawBitmap(dX, dY, dR - dX, dB - dY, pImageBuffer, unImageW, unImageH);
|
||||
}
|
||||
}
|
||||
void MoveTo(TEmfPointL& oPoint)
|
||||
{
|
||||
MoveTo(oPoint.x, oPoint.y);
|
||||
}
|
||||
void MoveTo(TEmfPointS& oPoint)
|
||||
{
|
||||
MoveTo(oPoint.x, oPoint.y);
|
||||
}
|
||||
void MoveTo(int nX, int nY)
|
||||
{
|
||||
double dX, dY;
|
||||
TranslatePoint(nX, nY, dX, dY);
|
||||
|
||||
//if (m_pPath)
|
||||
//{
|
||||
// if (!m_pPath->MoveTo(dX, dY))
|
||||
// return SetError();
|
||||
//}
|
||||
//else
|
||||
if (m_pOutput)
|
||||
{
|
||||
m_pOutput->MoveTo(dX, dY);
|
||||
}
|
||||
|
||||
m_pDC->SetCurPos(nX, nY);
|
||||
}
|
||||
void LineTo(int nX, int nY)
|
||||
{
|
||||
double dX, dY;
|
||||
TranslatePoint(nX, nY, dX, dY);
|
||||
|
||||
//if (m_pPath)
|
||||
//{
|
||||
// if (!m_pPath->LineTo(dX, dY))
|
||||
// return SetError();
|
||||
//}
|
||||
//else
|
||||
if (m_pOutput)
|
||||
{
|
||||
m_pOutput->LineTo(dX, dY);
|
||||
}
|
||||
|
||||
m_pDC->SetCurPos(nX, nY);
|
||||
}
|
||||
void LineTo(TSvmPoint& oPoint)
|
||||
{
|
||||
LineTo(oPoint.x, oPoint.y);
|
||||
}
|
||||
void CurveTo(int nX1, int nY1, int nX2, int nY2, int nXe, int nYe)
|
||||
{
|
||||
double dX1, dY1, dX2, dY2, dXe, dYe;
|
||||
TranslatePoint(nX1, nY1, dX1, dY1);
|
||||
TranslatePoint(nX2, nY2, dX2, dY2);
|
||||
TranslatePoint(nXe, nYe, dXe, dYe);
|
||||
|
||||
//if (m_pPath)
|
||||
//{
|
||||
// if (!m_pPath->CurveTo(dX1, dY1, dX2, dY2, dXe, dYe))
|
||||
// return SetError();
|
||||
//}
|
||||
//else
|
||||
if (m_pOutput)
|
||||
{
|
||||
m_pOutput->CurveTo(dX1, dY1, dX2, dY2, dXe, dYe);
|
||||
}
|
||||
|
||||
m_pDC->SetCurPos(nXe, nYe);
|
||||
}
|
||||
void CurveTo(TEmfPointS& oPoint1, TEmfPointS& oPoint2, TEmfPointS& oPointE)
|
||||
{
|
||||
CurveTo(oPoint1.x, oPoint1.y, oPoint2.x, oPoint2.y, oPointE.x, oPointE.y);
|
||||
}
|
||||
void CurveTo(TEmfPointL& oPoint1, TEmfPointL& oPoint2, TEmfPointL& oPointE)
|
||||
{
|
||||
CurveTo(oPoint1.x, oPoint1.y, oPoint2.x, oPoint2.y, oPointE.x, oPointE.y);
|
||||
}
|
||||
void ClosePath()
|
||||
{
|
||||
//if (m_pPath)
|
||||
//{
|
||||
// if (!m_pPath->Close())
|
||||
// return SetError();
|
||||
//}
|
||||
//else
|
||||
if (m_pOutput)
|
||||
m_pOutput->ClosePath();
|
||||
}
|
||||
void ArcTo(int nL, int nT, int nR, int nB, double dStart, double dSweep)
|
||||
{
|
||||
double dL, dT, dR, dB;
|
||||
TranslatePoint(nL, nT, dL, dT);
|
||||
TranslatePoint(nR, nB, dR, dB);
|
||||
|
||||
//if (m_pPath)
|
||||
//{
|
||||
// if (!m_pPath->ArcTo(dL, dT, dR, dB, dStart, dSweep))
|
||||
// return SetError();
|
||||
//}
|
||||
//else
|
||||
if (m_pOutput)
|
||||
{
|
||||
m_pOutput->ArcTo(dL, dT, dR, dB, dStart, dSweep);
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
void DrawPath(bool bStroke, bool bFill)
|
||||
{
|
||||
//if (m_pPath && m_pOutput)
|
||||
//{
|
||||
//}
|
||||
//else
|
||||
if (m_pOutput)
|
||||
{
|
||||
int lType = (bStroke ? 1 : 0) + (bFill ? 2 : 0);
|
||||
m_pOutput->DrawPath(lType);
|
||||
m_pOutput->EndPath();
|
||||
}
|
||||
}
|
||||
void UpdateOutputDC()
|
||||
{
|
||||
if (m_pOutput)
|
||||
m_pOutput->UpdateDC();
|
||||
}
|
||||
void DrawText(std::wstring& wsString, unsigned int unCharsCount, int _nX, int _nY, int* pnDx = NULL)
|
||||
{
|
||||
int nX = _nX;
|
||||
int nY = _nY;
|
||||
|
||||
if (m_pDC->GetTextAlign() & TA_UPDATECP)
|
||||
{
|
||||
nX = m_pDC->GetCurPos().x;
|
||||
nY = m_pDC->GetCurPos().y;
|
||||
}
|
||||
|
||||
if (m_pOutput)
|
||||
{
|
||||
double dX, dY;
|
||||
TranslatePoint(nX, nY, dX, dY);
|
||||
|
||||
double* pdDx = NULL;
|
||||
if (pnDx)
|
||||
{
|
||||
pdDx = new double[unCharsCount];
|
||||
if (pdDx)
|
||||
{
|
||||
int nCurX = nX;
|
||||
double dCurX = dX;
|
||||
|
||||
for (unsigned int unCharIndex = 0; unCharIndex < unCharsCount; unCharIndex++)
|
||||
{
|
||||
int nX1 = nCurX + pnDx[unCharIndex];
|
||||
double dX1, dY1;
|
||||
TranslatePoint(nX1, nY, dX1, dY1);
|
||||
pdDx[unCharIndex] = dX1 - dCurX;
|
||||
nCurX = nX1;
|
||||
dCurX = dX1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_pOutput->DrawString(wsString, unCharsCount, dX, dY, pdDx);
|
||||
|
||||
if (pdDx)
|
||||
delete[] pdDx;
|
||||
}
|
||||
}
|
||||
void DrawTextA(TEmfEmrText& oText)
|
||||
{
|
||||
if (!oText.OutputString)
|
||||
return SetError();
|
||||
|
||||
IFont* pFont = GetFont();
|
||||
NSString::CConverter::ESingleByteEncoding eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_DEFAULT;
|
||||
if (pFont)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Charset -> Codepage: http://support.microsoft.com/kb/165478
|
||||
// http://msdn.microsoft.com/en-us/library/cc194829.aspx
|
||||
// Charset Name Charset Value(hex) Codepage number
|
||||
// ------------------------------------------------------
|
||||
//
|
||||
// DEFAULT_CHARSET 1 (x01)
|
||||
// SYMBOL_CHARSET 2 (x02)
|
||||
// OEM_CHARSET 255 (xFF)
|
||||
// ANSI_CHARSET 0 (x00) 1252
|
||||
// RUSSIAN_CHARSET 204 (xCC) 1251
|
||||
// EASTEUROPE_CHARSET 238 (xEE) 1250
|
||||
// GREEK_CHARSET 161 (xA1) 1253
|
||||
// TURKISH_CHARSET 162 (xA2) 1254
|
||||
// BALTIC_CHARSET 186 (xBA) 1257
|
||||
// HEBREW_CHARSET 177 (xB1) 1255
|
||||
// ARABIC _CHARSET 178 (xB2) 1256
|
||||
// SHIFTJIS_CHARSET 128 (x80) 932
|
||||
// HANGEUL_CHARSET 129 (x81) 949
|
||||
// GB2313_CHARSET 134 (x86) 936
|
||||
// CHINESEBIG5_CHARSET 136 (x88) 950
|
||||
// THAI_CHARSET 222 (xDE) 874
|
||||
// JOHAB_CHARSET 130 (x82) 1361
|
||||
// VIETNAMESE_CHARSET 163 (xA3) 1258
|
||||
|
||||
switch (pFont->GetCharSet())
|
||||
{
|
||||
default:
|
||||
case DEFAULT_CHARSET: eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_DEFAULT; break;
|
||||
case SYMBOL_CHARSET: eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_DEFAULT; break;
|
||||
case ANSI_CHARSET: eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1252; break;
|
||||
case RUSSIAN_CHARSET: eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1251; break;
|
||||
case EASTEUROPE_CHARSET: eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1250; break;
|
||||
case GREEK_CHARSET: eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1253; break;
|
||||
case TURKISH_CHARSET: eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1254; break;
|
||||
case BALTIC_CHARSET: eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1257; break;
|
||||
case HEBREW_CHARSET: eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1255; break;
|
||||
case ARABIC_CHARSET: eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1256; break;
|
||||
case SHIFTJIS_CHARSET: eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP932; break;
|
||||
case HANGEUL_CHARSET: eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP949; break;
|
||||
case 134/*GB2313_CHARSET*/: eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP936; break;
|
||||
case CHINESEBIG5_CHARSET: eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP950; break;
|
||||
case THAI_CHARSET: eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP874; break;
|
||||
case JOHAB_CHARSET: eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1361; break;
|
||||
case VIETNAMESE_CHARSET: eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_CP1258; break;
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring wsText = NSString::CConverter::GetUnicodeFromSingleByteString((unsigned char*)oText.OutputString, oText.Chars, eCharSet);
|
||||
|
||||
int* pDx = NULL;
|
||||
if (oText.OutputDx)
|
||||
{
|
||||
pDx = new int[oText.Chars];
|
||||
if (pDx)
|
||||
{
|
||||
for (unsigned int unIndex = 0; unIndex < oText.Chars; unIndex++)
|
||||
{
|
||||
pDx[unIndex] = oText.OutputDx[unIndex];
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> Y <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
if (oText.Options & ETO_PDY)
|
||||
unIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DrawText(wsText, oText.Chars, oText.Reference.x, oText.Reference.y, pDx);
|
||||
|
||||
if (pDx)
|
||||
delete[] pDx;
|
||||
}
|
||||
void DrawTextW(TEmfEmrText& oText)
|
||||
{
|
||||
if (!oText.OutputString)
|
||||
return SetError();
|
||||
|
||||
std::wstring wsText = NSString::CConverter::GetUnicodeFromUTF16((unsigned short*)oText.OutputString, oText.Chars);
|
||||
|
||||
int* pDx = NULL;
|
||||
if (oText.OutputDx)
|
||||
{
|
||||
pDx = new int[oText.Chars];
|
||||
if (pDx)
|
||||
{
|
||||
for (unsigned int unIndex = 0; unIndex < oText.Chars; unIndex++)
|
||||
{
|
||||
pDx[unIndex] = oText.OutputDx[unIndex];
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> Y <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
if (oText.Options & ETO_PDY)
|
||||
unIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DrawText(wsText, oText.Chars, oText.Reference.x, oText.Reference.y, pDx);
|
||||
|
||||
if (pDx)
|
||||
delete[] pDx;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
294
DesktopEditor/raster/Metafile/StarView/SvmObjects.cpp
Normal file
294
DesktopEditor/raster/Metafile/StarView/SvmObjects.cpp
Normal file
@ -0,0 +1,294 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
314
DesktopEditor/raster/Metafile/StarView/SvmObjects.h
Normal file
314
DesktopEditor/raster/Metafile/StarView/SvmObjects.h
Normal file
@ -0,0 +1,314 @@
|
||||
#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;
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 32 <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
559
DesktopEditor/raster/Metafile/StarView/SvmPlayer.cpp
Normal file
559
DesktopEditor/raster/Metafile/StarView/SvmPlayer.cpp
Normal file
@ -0,0 +1,559 @@
|
||||
|
||||
#include "SvmPlayer.h"
|
||||
#include "SvmFile.h"
|
||||
|
||||
|
||||
|
||||
// MetaFile
|
||||
#include "SvmEnums.h"
|
||||
#include "SvmObjects.h"
|
||||
|
||||
#define DEBUG_SVMPAINT 0
|
||||
|
||||
|
||||
/**
|
||||
Namespace for StarView Metafile (SVM) classes
|
||||
*/
|
||||
namespace MetaFile
|
||||
{
|
||||
|
||||
CSvmPlayer::CSvmPlayer(CSvmFile* pFile)
|
||||
{
|
||||
CSvmDC* pDC = new CSvmDC();
|
||||
if (!pDC)
|
||||
{
|
||||
pFile->SetError();
|
||||
return;
|
||||
}
|
||||
|
||||
m_pDC = pDC;
|
||||
m_vDCStack.push_back(pDC);
|
||||
m_ushIndex = 0;
|
||||
|
||||
InitStockObjects();
|
||||
}
|
||||
|
||||
CSvmPlayer::~CSvmPlayer()
|
||||
{
|
||||
for (int nIndex = 0; nIndex < m_vDCStack.size(); nIndex++)
|
||||
{
|
||||
CSvmDC* pDC = m_vDCStack.at(nIndex);
|
||||
delete pDC;
|
||||
}
|
||||
m_vDCStack.clear();
|
||||
|
||||
for (CSvmObjectMap::iterator oIterator = m_mObjects.begin(); oIterator != m_mObjects.end(); oIterator++)
|
||||
{
|
||||
CSvmObjectBase* pOldObject = oIterator->second;
|
||||
delete pOldObject;
|
||||
}
|
||||
m_mObjects.clear();
|
||||
}
|
||||
|
||||
void CSvmPlayer::Clear()
|
||||
{
|
||||
for (int nIndex = 0; nIndex < m_vDCStack.size(); nIndex++)
|
||||
{
|
||||
CSvmDC* pDC = m_vDCStack.at(nIndex);
|
||||
delete pDC;
|
||||
}
|
||||
m_vDCStack.clear();
|
||||
|
||||
for (CSvmObjectMap::iterator oIterator = m_mObjects.begin(); oIterator != m_mObjects.end(); oIterator++)
|
||||
{
|
||||
CSvmObjectBase* pOldObject = oIterator->second;
|
||||
delete pOldObject;
|
||||
}
|
||||
m_mObjects.clear();
|
||||
|
||||
CSvmDC* pDC = new CSvmDC();
|
||||
if (!pDC)
|
||||
{
|
||||
m_pSvmFile->SetError();
|
||||
return;
|
||||
}
|
||||
|
||||
m_pDC = pDC;
|
||||
m_vDCStack.push_back(pDC);
|
||||
m_ushIndex = 0;
|
||||
m_vAvailableIndexes.clear();
|
||||
|
||||
InitStockObjects();
|
||||
|
||||
SelectObject(0x00000000); // BLACK_PEN
|
||||
SelectObject(0x00000001); // WHITE_BRUSH
|
||||
}
|
||||
void CSvmPlayer::SelectObject(unsigned short ushIndex)
|
||||
{
|
||||
CSvmObjectMap::const_iterator oPos = m_mObjects.find(ushIndex);
|
||||
if (m_mObjects.end() != oPos)
|
||||
{
|
||||
CSvmObjectBase* pObject = oPos->second;
|
||||
|
||||
|
||||
switch (pObject->GetType())
|
||||
{
|
||||
case SVM_OBJECT_BRUSH: m_pDC->SetBrush((CSvmBrush*)pObject); break;
|
||||
case SVM_OBJECT_FONT: m_pDC->SetFont((CSvmFont*)pObject); break;
|
||||
case SVM_OBJECT_PEN: m_pDC->SetPen((CSvmPen*)pObject); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
CSvmDC* CSvmPlayer::SaveDC()
|
||||
{
|
||||
if (!m_pDC)
|
||||
{
|
||||
m_pSvmFile->SetError();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CSvmDC* pNewDC = m_pDC->Copy();
|
||||
if (!pNewDC)
|
||||
{
|
||||
m_pSvmFile->SetError();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
m_vDCStack.push_back(pNewDC);
|
||||
m_pDC = pNewDC;
|
||||
return pNewDC;
|
||||
}
|
||||
CSvmDC* CSvmPlayer::RestoreDC()
|
||||
{
|
||||
if (m_vDCStack.size() <= 1)
|
||||
{
|
||||
m_pSvmFile->SetError();
|
||||
return m_pDC;
|
||||
}
|
||||
|
||||
CSvmDC* 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;
|
||||
}
|
||||
CSvmDC* CSvmPlayer::GetDC()
|
||||
{
|
||||
return m_pDC;
|
||||
}
|
||||
|
||||
void CSvmPlayer::RegisterObject(CSvmObjectBase* pObject)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
unsigned short ushIndex = m_ushIndex;
|
||||
int nAvailableIndex = -1;
|
||||
if (m_vAvailableIndexes.size() > 0)
|
||||
{
|
||||
for (std::size_t nIterator = 0; nIterator != m_vAvailableIndexes.size(); ++nIterator)
|
||||
{
|
||||
if (ushIndex > m_vAvailableIndexes[nIterator])
|
||||
{
|
||||
ushIndex = m_vAvailableIndexes[nIterator];
|
||||
nAvailableIndex = (int)nIterator;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CSvmObjectMap::const_iterator oPos = m_mObjects.find(ushIndex);
|
||||
if (m_mObjects.end() != oPos)
|
||||
{
|
||||
CSvmObjectBase* pOldObject = oPos->second;
|
||||
delete pOldObject;
|
||||
m_mObjects.erase(ushIndex);
|
||||
}
|
||||
|
||||
m_mObjects.insert(std::pair<unsigned int, CSvmObjectBase*>(ushIndex, pObject));
|
||||
|
||||
if (-1 != nAvailableIndex)
|
||||
m_vAvailableIndexes.erase(m_vAvailableIndexes.begin() + nAvailableIndex);
|
||||
|
||||
if (ushIndex == m_ushIndex)
|
||||
m_ushIndex++;
|
||||
}
|
||||
void CSvmPlayer::InitStockObjects()
|
||||
{
|
||||
InitStockBrush(false, 0x40, 0x40, 0x40);
|
||||
InitStockPen(false, 0x00, 0x00, 0x00);
|
||||
}
|
||||
void CSvmPlayer::InitStockBrush(bool bNull, unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
CSvmBrush* pBrush = new CSvmBrush();
|
||||
if (!pBrush)
|
||||
return;
|
||||
|
||||
if (bNull)
|
||||
pBrush->BrushStyle = BS_NULL;
|
||||
else
|
||||
{
|
||||
pBrush->BrushStyle = BS_SOLID;
|
||||
pBrush->Color.Set(r, g, b);
|
||||
}
|
||||
|
||||
RegisterObject((CSvmObjectBase*)pBrush);
|
||||
}
|
||||
void CSvmPlayer::InitStockPen(bool bNull, unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
CSvmPen* pPen = new CSvmPen();
|
||||
if (!pPen)
|
||||
return;
|
||||
|
||||
if (bNull)
|
||||
pPen->PenStyle = PS_NULL;
|
||||
else
|
||||
{
|
||||
pPen->PenStyle = PS_COSMETIC | PS_SOLID;
|
||||
pPen->Color.Set(r, g, b);
|
||||
}
|
||||
|
||||
RegisterObject((CSvmObjectBase*)pPen);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
CSvmDC::CSvmDC()
|
||||
{
|
||||
m_ulMapMode = MM_TEXT;
|
||||
m_pBrush = NULL;
|
||||
m_pPen = NULL;
|
||||
m_pFont = NULL;
|
||||
m_oTransform.Init();
|
||||
m_oInverseTransform.Init();
|
||||
m_oTextColor.Init();
|
||||
m_oBgColor.Init();
|
||||
m_ulTextAlign = TA_TOP | TA_LEFT | TA_NOUPDATECP;
|
||||
m_ulBgMode = TRANSPARENT;
|
||||
m_ulMiterLimit = 0;
|
||||
m_ulFillMode = WINDING;
|
||||
m_ulStretchMode = 0;
|
||||
m_oWindow.Init();
|
||||
m_oViewport.Init();
|
||||
m_dPixelHeight = 1;
|
||||
m_dPixelWidth = 1;
|
||||
m_oCurPos.x = 0;
|
||||
m_oCurPos.y = 0;
|
||||
m_unArcDirection = AD_COUNTERCLOCKWISE;
|
||||
}
|
||||
CSvmDC::~CSvmDC()
|
||||
{
|
||||
}
|
||||
CSvmDC* CSvmDC::Copy()
|
||||
{
|
||||
CSvmDC* pNewDC = new CSvmDC();
|
||||
if (!pNewDC)
|
||||
return NULL;
|
||||
|
||||
pNewDC->m_ulMapMode = m_ulMapMode;
|
||||
pNewDC->m_pBrush = m_pBrush;
|
||||
pNewDC->m_pPen = m_pPen;
|
||||
pNewDC->m_pFont = m_pFont;
|
||||
//pNewDC->m_pPalette = m_pPalette;
|
||||
pNewDC->m_oTransform.Copy(&m_oTransform);
|
||||
pNewDC->m_oInverseTransform.Copy(&m_oInverseTransform);
|
||||
pNewDC->m_oTextColor.Copy(m_oTextColor);
|
||||
pNewDC->m_oBgColor.Copy(m_oBgColor);
|
||||
pNewDC->m_ulTextAlign = m_ulTextAlign;
|
||||
pNewDC->m_ulBgMode = m_ulBgMode;
|
||||
pNewDC->m_ulMiterLimit = m_ulMiterLimit;
|
||||
pNewDC->m_ulFillMode = m_ulFillMode;
|
||||
pNewDC->m_ulStretchMode = m_ulStretchMode;
|
||||
pNewDC->m_ulRop2Mode = m_ulRop2Mode;
|
||||
pNewDC->m_dPixelHeight = m_dPixelHeight;
|
||||
pNewDC->m_dPixelWidth = m_dPixelWidth;
|
||||
pNewDC->m_oWindow.Copy(&m_oWindow);
|
||||
pNewDC->m_oViewport.Copy(&m_oViewport);
|
||||
pNewDC->m_oCurPos = m_oCurPos;
|
||||
//pNewDC->m_oClip = m_oClip;
|
||||
pNewDC->m_unArcDirection = m_unArcDirection;
|
||||
|
||||
return pNewDC;
|
||||
}
|
||||
void CSvmDC::SetMapMode(MapMode & mapMode)
|
||||
{
|
||||
m_ulMapMode = mapMode.isSimple ? MM_TWIPS : MM_TWIPS;
|
||||
|
||||
switch (m_ulMapMode)
|
||||
{
|
||||
case MM_TEXT: // 1 unit = 1pt
|
||||
{
|
||||
SetPixelWidth(1);
|
||||
SetPixelHeight(1);
|
||||
break;
|
||||
}
|
||||
case MM_LOMETRIC: // 1 unit = 0.1mm
|
||||
{
|
||||
double dPixel = 0.1 * 72 / 25.4;
|
||||
SetPixelWidth(dPixel);
|
||||
SetPixelHeight(dPixel);
|
||||
break;
|
||||
}
|
||||
case MM_HIMETRIC: // 1 unit = 0.01mm
|
||||
{
|
||||
double dPixel = 0.01 * 72 / 25.4;
|
||||
SetPixelWidth(dPixel);
|
||||
SetPixelHeight(dPixel);
|
||||
break;
|
||||
}
|
||||
case MM_LOENGLISH: // 1 unit = 0.01 inch
|
||||
{
|
||||
double dPixel = 0.01 * 72;
|
||||
SetPixelWidth(dPixel);
|
||||
SetPixelHeight(dPixel);
|
||||
break;
|
||||
}
|
||||
case MM_HIENGLISH: // 1 unit = 0.001 inch
|
||||
{
|
||||
double dPixel = 0.001 * 72;
|
||||
SetPixelWidth(dPixel);
|
||||
SetPixelHeight(dPixel);
|
||||
break;
|
||||
}
|
||||
case MM_TWIPS: // 1 unit = 1/1440 inch
|
||||
{
|
||||
SetPixelWidth(0.05);
|
||||
SetPixelHeight(0.05);
|
||||
break;
|
||||
}
|
||||
case MM_ISOTROPIC:
|
||||
case MM_ANISOTROPIC:
|
||||
{
|
||||
UpdatePixelMetrics();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TXForm* CSvmDC::GetTransform()
|
||||
{
|
||||
return &m_oTransform;
|
||||
}
|
||||
|
||||
TXForm* CSvmDC::GetInverseTransform()
|
||||
{
|
||||
return &m_oTransform;
|
||||
}
|
||||
|
||||
void CSvmDC::SetTextColor(TSvmColor& oColor)
|
||||
{
|
||||
m_oTextColor.Copy(oColor);
|
||||
}
|
||||
TSvmColor& CSvmDC::GetTextColor()
|
||||
{
|
||||
return m_oTextColor;
|
||||
}
|
||||
void CSvmDC::SetBrush(CSvmBrush* pBrush)
|
||||
{
|
||||
m_pBrush = pBrush;
|
||||
}
|
||||
void CSvmDC::RemoveBrush(CSvmBrush* pBrush)
|
||||
{
|
||||
if (pBrush == m_pBrush)
|
||||
m_pBrush = NULL;
|
||||
}
|
||||
CSvmBrush* CSvmDC::GetBrush()
|
||||
{
|
||||
return m_pBrush;
|
||||
}
|
||||
void CSvmDC::SetFont(CSvmFont* pFont)
|
||||
{
|
||||
m_pFont = pFont;
|
||||
}
|
||||
void CSvmDC::RemoveFont(CSvmFont* pFont)
|
||||
{
|
||||
if (pFont == m_pFont)
|
||||
m_pFont = NULL;
|
||||
}
|
||||
CSvmFont* CSvmDC::GetFont()
|
||||
{
|
||||
return m_pFont;
|
||||
}
|
||||
void CSvmDC::SetTextAlign(unsigned int ulAlign)
|
||||
{
|
||||
m_ulTextAlign = ulAlign;
|
||||
}
|
||||
unsigned int CSvmDC::GetTextAlign()
|
||||
{
|
||||
return m_ulTextAlign;
|
||||
}
|
||||
void CSvmDC::SetBgMode(unsigned int ulBgMode)
|
||||
{
|
||||
m_ulBgMode = ulBgMode;
|
||||
}
|
||||
unsigned int CSvmDC::GetBgMode()
|
||||
{
|
||||
return m_ulBgMode;
|
||||
}
|
||||
void CSvmDC::SetBgColor(TSvmColor& oColor)
|
||||
{
|
||||
m_oBgColor.Copy(oColor);
|
||||
}
|
||||
void CSvmDC::SetBgColor(TSvmColor* oColor)
|
||||
{
|
||||
m_oBgColor.Copy(*oColor);
|
||||
}
|
||||
TSvmColor& CSvmDC::GetBgColor()
|
||||
{
|
||||
return m_oBgColor;
|
||||
}
|
||||
void CSvmDC::SetMiterLimit(unsigned int ulMiter)
|
||||
{
|
||||
m_ulMiterLimit = ulMiter;
|
||||
}
|
||||
unsigned int CSvmDC::GetMiterLimit()
|
||||
{
|
||||
return m_ulMiterLimit;
|
||||
}
|
||||
void CSvmDC::SetFillMode(unsigned int ulFillMode)
|
||||
{
|
||||
m_ulFillMode = ulFillMode;
|
||||
}
|
||||
unsigned int CSvmDC::GetFillMode()
|
||||
{
|
||||
return m_ulFillMode;
|
||||
}
|
||||
void CSvmDC::SetPen(CSvmPen* pPen)
|
||||
{
|
||||
m_pPen = pPen;
|
||||
}
|
||||
void CSvmDC::RemovePen(CSvmPen* pPen)
|
||||
{
|
||||
if (pPen == m_pPen)
|
||||
m_pPen = NULL;
|
||||
}
|
||||
CSvmPen* CSvmDC::GetPen()
|
||||
{
|
||||
return m_pPen;
|
||||
}
|
||||
void CSvmDC::SetStretchMode(unsigned int& oMode)
|
||||
{
|
||||
m_ulStretchMode = oMode;
|
||||
}
|
||||
unsigned int CSvmDC::GetStretchMode()
|
||||
{
|
||||
return m_ulStretchMode;
|
||||
}
|
||||
double CSvmDC::GetPixelWidth()
|
||||
{
|
||||
return m_dPixelWidth;
|
||||
}
|
||||
double CSvmDC::GetPixelHeight()
|
||||
{
|
||||
return m_dPixelHeight;
|
||||
}
|
||||
void CSvmDC::SetPixelWidth(double dPixelW)
|
||||
{
|
||||
m_dPixelWidth = dPixelW;
|
||||
}
|
||||
void CSvmDC::SetPixelHeight(double dPixelH)
|
||||
{
|
||||
m_dPixelHeight = dPixelH;
|
||||
}
|
||||
void CSvmDC::SetWindowOrigin(TSvmPoint& oPoint)
|
||||
{
|
||||
m_oWindow.lX = oPoint.x;
|
||||
m_oWindow.lY = oPoint.y;
|
||||
UpdatePixelMetrics();
|
||||
}
|
||||
void CSvmDC::SetWindowExtents(TSvmSize& oPoint)
|
||||
{
|
||||
m_oWindow.ulW = oPoint.cx;
|
||||
m_oWindow.ulH = oPoint.cy;
|
||||
UpdatePixelMetrics();
|
||||
}
|
||||
TSvmWindow* CSvmDC::GetWindow()
|
||||
{
|
||||
return &m_oWindow;
|
||||
}
|
||||
void CSvmDC::SetViewportOrigin(TSvmPoint& oPoint)
|
||||
{
|
||||
m_oViewport.lX = oPoint.x;
|
||||
m_oViewport.lY = oPoint.y;
|
||||
UpdatePixelMetrics();
|
||||
}
|
||||
void CSvmDC::SetViewportExtents(TSvmSize& oPoint)
|
||||
{
|
||||
m_oViewport.ulW = oPoint.cx;
|
||||
m_oViewport.ulH = oPoint.cy;
|
||||
UpdatePixelMetrics();
|
||||
}
|
||||
TSvmWindow* CSvmDC::GetViewport()
|
||||
{
|
||||
return &m_oViewport;
|
||||
}
|
||||
bool CSvmDC::UpdatePixelMetrics()
|
||||
{
|
||||
unsigned int ulMapMode = m_ulMapMode;
|
||||
if (MM_ISOTROPIC == ulMapMode)
|
||||
{
|
||||
if (0 == m_oWindow.ulW || 0 == m_oViewport.ulW)
|
||||
return false;
|
||||
|
||||
double dPixel = (double)m_oViewport.ulW / (double)m_oWindow.ulW;
|
||||
SetPixelHeight(dPixel);
|
||||
SetPixelWidth(dPixel);
|
||||
}
|
||||
else if (MM_ANISOTROPIC == ulMapMode)
|
||||
{
|
||||
double dPixelX = (double)m_oViewport.ulW / (double)m_oWindow.ulW;
|
||||
double dPixelY = (double)m_oViewport.ulH / (double)m_oWindow.ulH;
|
||||
|
||||
SetPixelWidth(dPixelX);
|
||||
SetPixelHeight(dPixelY);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
void CSvmDC::SetRop2Mode(unsigned int& nMode)
|
||||
{
|
||||
m_ulRop2Mode = nMode;
|
||||
}
|
||||
unsigned int CSvmDC::GetRop2Mode()
|
||||
{
|
||||
return m_ulRop2Mode;
|
||||
}
|
||||
//void CSvmDC::SetPalette(CSvmPalette* pPalette)
|
||||
//{
|
||||
// m_pPalette = pPalette;
|
||||
//}
|
||||
//void CSvmDC::RemovePalette(CSvmPalette* pPalette)
|
||||
//{
|
||||
// if (m_pPalette == pPalette)
|
||||
// m_pPalette = NULL;
|
||||
//}
|
||||
//CSvmPalette* CSvmDC::GetPalette()
|
||||
//{
|
||||
// return m_pPalette;
|
||||
//}
|
||||
void CSvmDC::SetCurPos(TSvmPoint& oPoint)
|
||||
{
|
||||
SetCurPos(oPoint.x, oPoint.y);
|
||||
}
|
||||
void CSvmDC::SetCurPos(int lX, int lY)
|
||||
{
|
||||
m_oCurPos.x = lX;
|
||||
m_oCurPos.y = lY;
|
||||
}
|
||||
TSvmPoint & CSvmDC::GetCurPos()
|
||||
{
|
||||
return m_oCurPos;
|
||||
}
|
||||
//CSvmClip* CSvmDC::GetClip()
|
||||
//{
|
||||
// return &m_oClip;
|
||||
//}
|
||||
//void CSvmDC::ClipToPath(CSvmPath* pPath, unsigned int unMode)
|
||||
//{
|
||||
// m_oClip.SetPath(pPath, unMode);
|
||||
//}
|
||||
void CSvmDC::SetArcDirection(unsigned int unDirection)
|
||||
{
|
||||
m_unArcDirection = unDirection;
|
||||
}
|
||||
unsigned int CSvmDC::GetArcDirection()
|
||||
{
|
||||
return m_unArcDirection;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
141
DesktopEditor/raster/Metafile/StarView/SvmPlayer.h
Normal file
141
DesktopEditor/raster/Metafile/StarView/SvmPlayer.h
Normal file
@ -0,0 +1,141 @@
|
||||
|
||||
#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);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#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
|
||||
|
||||
Reference in New Issue
Block a user