-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
160 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using JetBrains.Annotations; | ||
|
||
namespace SharpEmf.Enums; | ||
|
||
/// <summary> | ||
/// Specifies the different possible brush types that can be used in graphics operations | ||
/// </summary> | ||
[PublicAPI] | ||
public enum BrushStyle : uint | ||
{ | ||
BS_SOLID = 0x0000, | ||
BS_NULL = 0x0001, | ||
BS_HATCHED = 0x0002, | ||
BS_PATTERN = 0x0003, | ||
BS_INDEXED = 0x0004, | ||
BS_DIBPATTERN = 0x0005, | ||
BS_DIBPATTERNPT = 0x0006, | ||
BS_PATTERN8X8 = 0x0007, | ||
BS_DIBPATTERN8X8 = 0x0008, | ||
BS_MONOPATTERN = 0x0009 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using JetBrains.Annotations; | ||
|
||
namespace SharpEmf.Enums; | ||
|
||
/// <summary> | ||
/// Specifies the hatch pattern | ||
/// </summary> | ||
[PublicAPI] | ||
public enum HatchStyle : uint | ||
{ | ||
HS_SOLIDCLR = 0x0006, | ||
HS_DITHEREDCLR = 0x0007, | ||
HS_SOLIDTEXTCLR = 0x0008, | ||
HS_DITHEREDTEXTCLR = 0x0009, | ||
HS_SOLIDBKCLR = 0x000A, | ||
HS_DITHEREDBKCLR = 0x000B | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using JetBrains.Annotations; | ||
using SharpEmf.Enums; | ||
using SharpEmf.Exceptions; | ||
using SharpEmf.Extensions; | ||
|
||
namespace SharpEmf.Objects; | ||
|
||
/// <summary> | ||
/// Defines the style, color, and pattern of a device-independent brush | ||
/// </summary> | ||
/// <remarks> | ||
/// The following table shows the relationship between the BrushStyle, Color, and BrushHatch fields: | ||
/// <code> | ||
/// | BrushStyle | Color | BrushHatch | ||
/// |--------------|-----------------------------------------------------|-------------------------------------------------------------| | ||
/// | BS_SOLID | Specifies the color of the brush | Not used and SHOULD be ignored | | ||
/// | BS_NULL | Not used and SHOULD be ignored | Not used and SHOULD be ignored | | ||
/// | BS_HATCHED | Specifies the foreground color of the hatch pattern | Specifies the orientation of lines used to create the hatch | | ||
/// </code> | ||
/// </remarks> | ||
[PublicAPI] | ||
public readonly struct LogBrushEx | ||
{ | ||
/// <summary> | ||
/// Specifies the brush style. | ||
/// Values of this field MUST be <see cref="BrushStyle.BS_SOLID"/>, <see cref="BrushStyle.BS_HATCHED"/>, or <see cref="BrushStyle.BS_NULL"/> | ||
/// </summary> | ||
public BrushStyle BrushStyle { get; } | ||
|
||
/// <summary> | ||
/// Specifies a color | ||
/// </summary> | ||
public ColorRef Color { get; } | ||
|
||
/// <summary> | ||
/// Brush hatch data | ||
/// </summary> | ||
public HatchStyle HatchStyle { get; } | ||
|
||
private LogBrushEx(BrushStyle brushStyle, ColorRef color, HatchStyle hatchStyle) | ||
{ | ||
BrushStyle = brushStyle; | ||
Color = color; | ||
HatchStyle = hatchStyle; | ||
} | ||
|
||
public static LogBrushEx Parse(Stream stream) | ||
{ | ||
var brushStyle = stream.ReadEnum<BrushStyle>(); | ||
|
||
if (brushStyle is not (BrushStyle.BS_SOLID or BrushStyle.BS_HATCHED or BrushStyle.BS_NULL)) | ||
{ | ||
throw new EmfParseException($"Invalid {nameof(BrushStyle)} value: {brushStyle}"); | ||
} | ||
|
||
var color = ColorRef.Parse(stream); | ||
var hatchStyle = stream.ReadEnum<HatchStyle>(); | ||
|
||
return new LogBrushEx(brushStyle, color, hatchStyle); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/SharpEmf/Records/ObjectCreation/EmrCreateBrushIndirect.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using JetBrains.Annotations; | ||
using SharpEmf.Enums; | ||
using SharpEmf.Extensions; | ||
using SharpEmf.Interfaces; | ||
using SharpEmf.Objects; | ||
|
||
namespace SharpEmf.Records.ObjectCreation; | ||
|
||
/// <inheritdoc cref="EmfRecordType.EMR_CREATEBRUSHINDIRECT"/> | ||
[PublicAPI] | ||
public record EmrCreateBrushIndirect : EnhancedMetafileRecord, IEmfParsable<EmrCreateBrushIndirect> | ||
{ | ||
/// <summary> | ||
/// Specifies the index of the logical brush object in the EMF object table | ||
/// </summary> | ||
/// <remarks> | ||
/// This index is used to refer to the object, so it can be reused or modified | ||
/// </remarks> | ||
public uint IHBrush { get; } | ||
|
||
/// <summary> | ||
/// Specifies the style, color, and pattern of the logical brush | ||
/// </summary> | ||
public LogBrushEx LogBrush { get; } | ||
|
||
private EmrCreateBrushIndirect(EmfRecordType Type, uint Size, uint ihBrush, LogBrushEx logBrush) : base(Type, Size) | ||
{ | ||
IHBrush = ihBrush; | ||
LogBrush = logBrush; | ||
} | ||
|
||
public static EmrCreateBrushIndirect Parse(Stream stream, EmfRecordType recordType, uint size) | ||
{ | ||
var ihBrush = stream.ReadUInt32(); | ||
var logBrush = LogBrushEx.Parse(stream); | ||
|
||
return new EmrCreateBrushIndirect(recordType, size, ihBrush, logBrush); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters