Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ jobs:
if ($failed) { exit 1 }
env:
PDF_OUTPUT_DIRECTORY: ${{ github.workspace }}/pdf-artifacts/${{ matrix.platform.name }}-${{ matrix.dotnet.name }}
HTML_RENDERER_REGRESSION_OUTPUT_DIRECTORY: ${{ github.workspace }}/image-regression/${{ matrix.platform.name }}-${{ matrix.dotnet.name }}

- name: Spec compliance report
if: ${{ !cancelled() && runner.os == 'Windows' && matrix.dotnet.name == '.NET 8' }}
Expand All @@ -101,6 +102,9 @@ jobs:
- name: Create HtmlRenderer.PdfSharp NuGet package
run: dotnet pack Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj --configuration Release --include-symbols -p:SymbolPackageFormat=snupkg --no-build --verbosity normal --output ${{ env.NuGetDirectory }}

- name: Create HtmlRenderer.SkiaSharp NuGet package
run: dotnet pack Source/HtmlRenderer.SkiaSharp/HtmlRenderer.SkiaSharp.csproj --configuration Release --include-symbols -p:SymbolPackageFormat=snupkg --no-build --verbosity normal --output ${{ env.NuGetDirectory }}

- name: Create HtmlRenderer.WinForms NuGet package
run: dotnet pack Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj --configuration Release --include-symbols -p:SymbolPackageFormat=snupkg --no-build --verbosity normal --output ${{ env.NuGetDirectory }}

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The latest NuGet packages can be found on NuGet.org:
* [HtmlRenderer.WinForms](https://www.nuget.org/packages/HtmlRenderer.WinForms)
* [HtmlRenderer.WPF](https://www.nuget.org/packages/HtmlRenderer.WPF)
* [HtmlRenderer.PdfSharp](https://www.nuget.org/packages/HtmlRenderer.PdfSharp)
* [HtmlRenderer.SkiaSharp](https://www.nuget.org/packages/HtmlRenderer.SkiaSharp)
* [HtmlRenderer.Core](https://www.nuget.org/packages/HtmlRenderer.Core)


Expand Down
2 changes: 2 additions & 0 deletions Source/HtmlRenderer.CrossPlatform.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
"Demo\\WPF\\HtmlRenderer.Demo.WPF.csproj",
"HtmlRenderer\\HtmlRenderer.csproj",
"HtmlRenderer.PdfSharp\\HtmlRenderer.PdfSharp.csproj",
"HtmlRenderer.SkiaSharp\\HtmlRenderer.SkiaSharp.csproj",
"HtmlRenderer.WinForms\\HtmlRenderer.WinForms.csproj",
"HtmlRenderer.WPF\\HtmlRenderer.WPF.csproj",
"Test\\HtmlRenderer.IntegrationTest\\HtmlRenderer.IntegrationTest.csproj",
"Test\\HtmlRenderer.PdfSharp.Test\\HtmlRenderer.PdfSharp.Test.csproj",
"Test\\HtmlRenderer.SkiaSharp.Test\\HtmlRenderer.SkiaSharp.Test.csproj",
"Test\\HtmlRenderer.Test\\HtmlRenderer.Test.csproj",
"Tools\\HtmlRenderer.SpecCompliance\\HtmlRenderer.SpecCompliance.csproj"
]
Expand Down
57 changes: 57 additions & 0 deletions Source/HtmlRenderer.SkiaSharp/Adapters/BrushAdapter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// "Therefore those skilled at the unorthodox
// are infinite as heaven and earth,
// inexhaustible as the great rivers.
// When they come to an end,
// they begin again,
// like the days and months;
// they die and are reborn,
// like the four seasons."
//
// - Sun Tsu,
// "The Art of War"

using SkiaSharp;
using TheArtOfDev.HtmlRenderer.Adapters;

namespace TheArtOfDev.HtmlRenderer.SkiaSharp.Adapters
{
/// <summary>
/// Adapter for SkiaSharp brushes: a solid color, or a shader for gradients and images.
/// </summary>
internal sealed class BrushAdapter : RBrush
{
private readonly SKColor _color;

private SKShader _shader;

public BrushAdapter(SKColor color)
{
_color = color;
}

public BrushAdapter(SKShader shader)
{
_color = SKColors.Black;
_shader = shader;
}

/// <summary>
/// Sets up the paint to fill with this brush.
/// </summary>
public void Apply(SKPaint paint)
{
paint.Style = SKPaintStyle.Fill;
paint.Color = _color;
paint.Shader = _shader;
}

/// <summary>
/// Only releases the shader, the core also disposes the cached solid brushes and uses them again afterwards.
/// </summary>
public override void Dispose()
{
_shader?.Dispose();
_shader = null;
}
}
}
Loading
Loading