Skip to content

Commit

Permalink
Add more emf records parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
KeterSCP committed Dec 9, 2023
1 parent a32e794 commit 0220ced
Show file tree
Hide file tree
Showing 25 changed files with 816 additions and 31 deletions.
26 changes: 26 additions & 0 deletions SharpEmf.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=CLOSECHANNEL/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=CLOSEFIGURE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=CREATEBRUSHINDIRECT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=DASHDOT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=DASHDOTDOT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=DELETEOBJECT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=DIBPATTERN/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=DIBPATTERNPT/@EntryIndexedValue">True</s:Boolean>
Expand All @@ -24,13 +26,16 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=DRAWESCAPE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=DRAWPATTERNRECT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ENABLEDUPLEX/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ENDCAP/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ENDDOC/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ENDPATH/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Enhmeta/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ENUMPAPERBINS/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ENUMPAPERMETRICS/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=EPSF/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=EPSPRINTING/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=EXCLUDECLIPRECT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=EXTCREATEPEN/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=EXTESCAPE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=EXTFLOODFILL/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=EXTSELECTCLIPRGN/@EntryIndexedValue">True</s:Boolean>
Expand All @@ -45,6 +50,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=FLOODFILLSURFACE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=FLUSHOUT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=FRAMERGN/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=FSPE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=GETCOLORTABLE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=GETDEVICEUNITS/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=GETEXTENDEDTEXTMETRICS/@EntryIndexedValue">True</s:Boolean>
Expand All @@ -60,11 +66,18 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=GETVECTORBRUSHSIZE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=GETVECTORPENSIZE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=GRADIENTFILL/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=HIENGLISH/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=HIMETRIC/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=IGNORELANGUAGE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=INSIDEFRAME/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=intercharacter/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=INTERSECTCLIPRECT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=LEFTMULTIPLY/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Lineto/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=LOENGLISH/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=LOMETRIC/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=LTGRAY/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=MODIFYWORLDTRANSFORM/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=MONOPATTERN/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=MOVETOEX/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=MXDC/@EntryIndexedValue">True</s:Boolean>
Expand All @@ -91,21 +104,31 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=POLYTEXTOUTW/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=QUERYDIBSUPPORT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=QUERYESCSUPPORT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=RESTOREDC/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=RIGHTMULTIPLY/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ROUNDRECT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=RTLREADING/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SAVEDC/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SELECTCLIPPATH/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SELECTOBJECT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETABORTPROC/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETBKMODE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETCOLORTABLE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETCOPYCOUNT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETDIBSCALING/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETLINECAP/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETLINEJOIN/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETMAPMODE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETMITERLIMIT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETPAPERSOURCE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETPENWIDTH/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETPIXELV/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETPOLYFILLMODE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETVIEWPORTEXTEX/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETVIEWPORTORGEX/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETWINDOWEXTEX/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETWINDOWORGEX/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SETWORLDTRANSFORM/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SMALLTEXTOUT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SOLIDBKCLR/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SOLIDCLR/@EntryIndexedValue">True</s:Boolean>
Expand All @@ -116,5 +139,8 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=STRETCHDIBITS/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=STROKEANDFILLPATH/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Strokepath/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=twip/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=TWIPS/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=USERSTYLE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=wideline/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=WIDENPATH/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
21 changes: 21 additions & 0 deletions src/SharpEmf/Enums/BackgroundMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using JetBrains.Annotations;

namespace SharpEmf.Enums;

/// <summary>
/// Used to specify the background mode to be used with text, hatched brushes, and pen styles that are not solid.
/// The background mode determines how to combine the background with foreground text, hatched brushes, and pen styles that are not solid lines
/// </summary>
[PublicAPI]
public enum BackgroundMode : uint
{
/// <summary>
/// Background remains untouched
/// </summary>
TRANSPARENT = 0x0001,

/// <summary>
/// Background is filled with the current background color before the text, hatched brush, or pen is drawn
/// </summary>
OPAQUE = 0x0002
}
56 changes: 56 additions & 0 deletions src/SharpEmf/Enums/EmfRecordType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,37 @@ public enum EmfRecordType : uint
/// </remarks>
EMR_POLYPOLYGON = 0x00000008,

/// <summary>
/// Defines the window extent
/// </summary>
EMR_SETWINDOWEXTEX = 0x00000009,

/// <summary>
/// Defines the window origin
/// </summary>
EMR_SETWINDOWORGEX = 0x0000000A,

/// <summary>
/// Defines the viewport extent
/// </summary>
EMR_SETVIEWPORTEXTEX = 0x0000000B,

/// <summary>
/// Defines the viewport origin
/// </summary>
EMR_SETVIEWPORTORGEX = 0x0000000C,

/// <summary>
/// Defines the mapping mode, which defines the unit of measure used to transform page space units into device space units,
/// and defines the orientation of the device's X and Y axes
/// </summary>
EMR_SETMAPMODE = 0x00000011,

/// <summary>
/// Defines the background mix mode, which is used with text, hatched brushes, and pen styles that are not solid lines
/// </summary>
EMR_SETBKMODE = 0x00000012,

/// <summary>
/// Defines polygon fill mode
/// </summary>
Expand Down Expand Up @@ -110,6 +141,26 @@ public enum EmfRecordType : uint
/// </summary>
EMR_INTERSECTCLIPRECT = 0x0000001E,

/// <summary>
/// Saves the current state of the playback device context in an array of states
/// </summary>
EMR_SAVEDC = 0x00000021,

/// <summary>
/// Restores the playback device context to the specified state, which was saved by a preceding <see cref="EMR_SAVEDC"/> record
/// </summary>
EMR_RESTOREDC = 0x00000022,

/// <summary>
/// Defines a two-dimensional linear transform between world space and page space
/// </summary>
EMR_SETWORLDTRANSFORM = 0x00000023,

/// <summary>
/// Redefines the world transform by using the specified mode
/// </summary>
EMR_MODIFYWORLDTRANSFORM = 0x00000024,

/// <summary>
/// Selects an object in the playback device context, which is identified by its index in the EMF object table
/// </summary>
Expand Down Expand Up @@ -369,6 +420,11 @@ public enum EmfRecordType : uint
/// <inheritdoc cref="EMR_POLYDRAW"/>
EMR_POLYDRAW16 = 0x0000005C,

/// <summary>
/// Defines an extended logical pen that has the specified style, width, color, and brush attributes
/// </summary>
EMR_EXTCREATEPEN = 0x0000005F,

/// <summary>
/// Draws one or more ASCII text strings using the current font and text colors
/// </summary>
Expand Down
44 changes: 44 additions & 0 deletions src/SharpEmf/Enums/MapMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using JetBrains.Annotations;

namespace SharpEmf.Enums;

/// <summary>
/// Used to define the unit of measure for transforming page space units into device space units and for defining the orientation of the drawing axes
/// </summary>
[PublicAPI]
public enum MapMode : uint
{
/// <summary>
/// Each logical unit is mapped to one device pixel. Positive x is to the right; positive y is down
/// </summary>
MM_TEXT = 0x01,
/// <summary>
/// Each logical unit is mapped to 0.1 millimeter. Positive x is to the right; positive y is up
/// </summary>
MM_LOMETRIC = 0x02,
/// <summary>
/// Each logical unit is mapped to 0.01 millimeter. Positive x is to the right; positive y is up
/// </summary>
MM_HIMETRIC = 0x03,
/// <summary>
/// Each logical unit is mapped to 0.01 inch. Positive x is to the right; positive y is up
/// </summary>
MM_LOENGLISH = 0x04,
/// <summary>
///Each logical unit is mapped to 0.001 inch. Positive x is to the right; positive y is up
/// </summary>
MM_HIENGLISH = 0x05,
/// <summary>
/// Each logical unit is mapped to one-twentieth of a printer's point (1/1440 inch, also called a "twip"). Positive x is to the right; positive y is up
/// </summary>
MM_TWIPS = 0x06,
/// <summary>
/// Logical units are isotropic; that is, they are mapped to arbitrary units with equally scaled axes.
/// Thus, one unit along the x-axis is equal to one unit along the y-axis
/// </summary>
MM_ISOTROPIC = 0x07,
/// <summary>
/// Logical units are anisotropic; that is, they are mapped to arbitrary units with arbitrarily scaled axes
/// </summary>
MM_ANISOTROPIC = 0x08
}
30 changes: 30 additions & 0 deletions src/SharpEmf/Enums/ModifyWorldTransformMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using JetBrains.Annotations;

namespace SharpEmf.Enums;

/// <summary>
/// Defines modes for changing the world-space to page-space transform that is currently defined in the playback device context
/// </summary>
[PublicAPI]
public enum ModifyWorldTransformMode : uint
{
/// <summary>
/// Reset the current transform using the identity matrix. In this mode, the specified transform data is ignored
/// </summary>
MWT_IDENTITY = 0x01,

/// <summary>
/// Multiply the current transform. In this mode, the specified transform data is the left multiplicand, and the current transform is the right multiplicand
/// </summary>
MWT_LEFTMULTIPLY = 0x02,

/// <summary>
/// Multiply the current transform. In this mode, the specified transform data is the right multiplicand, and the current transform is the left multiplicand
/// </summary>
MWT_RIGHTMULTIPLY = 0x03,

/// <summary>
/// Set the current transform to the specified transform data
/// </summary>
MWT_SET = 0x04
}
105 changes: 105 additions & 0 deletions src/SharpEmf/Enums/PenStyle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using JetBrains.Annotations;

namespace SharpEmf.Enums;

/// <summary>
/// Defines the attributes of pens that can be used in graphics operations.
/// A pen style is a combination of pen type, line style, line cap, and line join
/// </summary>
[PublicAPI]
public enum PenStyle : uint
{
/// <summary>
/// A pen type that specifies a line with a width of one logical unit and a style that is a solid color
/// </summary>
PS_COSMETIC = 0x00000000,

/// <summary>
/// A line cap that specifies round ends
/// </summary>
PS_ENDCAP_ROUND = 0x00000000,

/// <summary>
/// A line join that specifies round joins
/// </summary>
PS_JOIN_ROUND = 0x00000000,

/// <summary>
/// A line style that is a solid color
/// </summary>
PS_SOLID = 0x00000000,

/// <summary>
/// A line style that is dashed
/// </summary>
PS_DASH = 0x00000001,

/// <summary>
/// A line style that is dotted
/// </summary>
PS_DOT = 0x00000002,

/// <summary>
/// A line style that consists of alternating dashes and dots
/// </summary>
PS_DASHDOT = 0x00000003,

/// <summary>
/// A line style that consists of dashes and double dots
/// </summary>
PS_DASHDOTDOT = 0x00000004,

/// <summary>
/// A line style that is invisible
/// </summary>
PS_NULL = 0x00000005,

/// <summary>
/// A line style that is a solid color
/// </summary>
/// <remarks>
/// When this style is specified in a drawing record that takes a bounding rectangle,
/// the dimensions of the figure are shrunk so that it fits entirely in the bounding rectangle, considering the width of the pen
/// </remarks>
PS_INSIDEFRAME = 0x00000006,

/// <summary>
/// A line style that is defined by a styling array, which specifies the lengths of dashes and gaps in the line
/// </summary>
PS_USERSTYLE = 0x00000007,

/// <summary>
/// A line style in which every other pixel is set. This style is applicable only to a pen type of <see cref="PS_COSMETIC"/>
/// </summary>
PS_ALTERNATE = 0x00000008,

/// <summary>
/// A line cap that specifies square ends
/// </summary>
PS_ENDCAP_SQUARE = 0x00000100,

/// <summary>
/// A line cap that specifies flat ends
/// </summary>
PS_ENDCAP_FLAT = 0x00000200,

/// <summary>
/// A line join that specifies beveled joins
/// </summary>
PS_JOIN_BEVEL = 0x00001000,

// TODO: add cref
/// <summary>
/// A line join that specifies mitered joins when the lengths of the joins are within the current miter length limit.
/// If the lengths of the joins exceed the miter limit, beveled joins are specified
/// </summary>
/// <remarks>
/// The miter length limit is a metafile state property that is set by the EMR_SETMITERLIMIT record
/// </remarks>
PS_JOIN_MITER = 0x00002000,

/// <summary>
/// A pen type that specifies a line with a width that is measured in logical units and a style that can contain any of the attributes of a brush
/// </summary>
PS_GEOMETRIC = 0x00010000
}
Loading

0 comments on commit 0220ced

Please sign in to comment.