Skip to content

Commit 520a86a

Browse files
committed
update SixLabors
1 parent 83d529c commit 520a86a

20 files changed

+66
-28
lines changed

Packages.props

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
<PackageReference Update="Newtonsoft.Json" Version="12.0.3" />
77
<PackageReference Update="NuGet.Build.Packaging" Version="0.2.5-dev.10" />
88
<PackageReference Update="Microsoft.Web.Xdt" Version="3.0.0" />
9+
10+
<PackageReference Update="SixLabors.ImageSharp" Version="1.0.3" />
11+
<PackageReference Update="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta11" />
12+
<PackageReference Update="SixLabors.Fonts" Version="1.0.0-beta0013" />
13+
14+
<PackageReference Update="System.Buffers" Version="4.5.1" />
15+
<PackageReference Update="System.Memory" Version="4.5.4" />
16+
<PackageReference Update="System.Numerics.Vectors" Version="4.5.0" />
17+
<PackageReference Update="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
918
</ItemGroup>
1019

1120
<ItemGroup>
Binary file not shown.

assets/runtime/SixLabors.Core.dll

-34.5 KB
Binary file not shown.

assets/runtime/SixLabors.Fonts.dll

-82 KB
Binary file not shown.
-56.5 KB
Binary file not shown.
-892 KB
Binary file not shown.

assets/runtime/SixLabors.Shapes.dll

-99.5 KB
Binary file not shown.

assets/runtime/System.Buffers.dll

-27.3 KB
Binary file not shown.
-295 KB
Binary file not shown.

assets/runtime/System.Memory.dll

-145 KB
Binary file not shown.
-113 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

src/Mobile.BuildTools/Drawing/ColorUtils.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ namespace Mobile.BuildTools.Drawing
88
{
99
internal static class ColorUtils
1010
{
11-
private static readonly Dictionary<string, Rgba32> namedColors = typeof(Rgba32).GetFields(BindingFlags.Public | BindingFlags.Static)
12-
.Where(x => x.FieldType == typeof(Rgba32))
13-
.ToDictionary(x => x.Name, x => (Rgba32)x.GetValue(null));
11+
private static readonly Dictionary<string, Color> namedColors = typeof(Color).GetFields(BindingFlags.Public | BindingFlags.Static)
12+
.Where(x => x.FieldType == typeof(Color))
13+
.ToDictionary(x => x.Name, x => (Color)x.GetValue(null));
1414

1515
public static bool TryParse(string input, out Color result)
1616
{
1717
result = default;
18-
18+
1919
if (string.IsNullOrWhiteSpace(input))
2020
{
2121
return false;
@@ -28,7 +28,7 @@ public static bool TryParse(string input, out Color result)
2828

2929
try
3030
{
31-
result = Rgba32.FromHex(input);
31+
result = Rgba32.ParseHex(input);
3232
return true;
3333
}
3434
catch

src/Mobile.BuildTools/Drawing/IconUtils.cs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Globalization;
3-
using SixLabors.ImageSharp;
4-
using SixLabors.ImageSharp.Advanced;
1+
using SixLabors.ImageSharp;
52
using SixLabors.ImageSharp.PixelFormats;
63
using SixLabors.ImageSharp.Processing;
74

@@ -28,8 +25,8 @@ public static bool HasTransparentBackground(this Image image)
2825
}
2926

3027
public static void ApplyBackground(this IImageProcessingContext context, string hexColor)
31-
{
32-
var color = ColorUtils.TryParse(hexColor, out var x) ? x : Color.FromHex(Constants.DefaultBackgroundColor);
28+
{
29+
var color = ColorUtils.TryParse(hexColor, out var x) ? x : Color.ParseHex(Constants.DefaultBackgroundColor);
3330

3431
context.BackgroundColor(color);
3532
}

src/Mobile.BuildTools/Drawing/Watermark.cs

+31-12
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
using SixLabors.ImageSharp.Processing;
88
using Mobile.BuildTools.Models.AppIcons;
99
using SixLabors.Fonts;
10-
using SixLabors.Primitives;
11-
using SixLabors.Shapes;
12-
10+
using SixLabors.ImageSharp.Drawing.Processing;
11+
using SixLabors.ImageSharp.Drawing;
12+
1313
namespace Mobile.BuildTools.Drawing
1414
{
1515
public static class Watermark
@@ -97,12 +97,19 @@ private static IImageProcessingContext DrawWatermark(this IImageProcessingContex
9797
WatermarkPosition.TopLeft => new PointF(imgSize.Width / 2, (imgSize.Height / 9)),
9898
WatermarkPosition.TopRight => new PointF(imgSize.Width / 2, (imgSize.Height / 9)),
9999
_ => new PointF(imgSize.Width / 2, imgSize.Height - (imgSize.Height / 9)),
100-
};
101-
102-
var textGraphicOptions = new TextGraphicsOptions(true)
103-
{
104-
HorizontalAlignment = HorizontalAlignment.Center,
105-
VerticalAlignment = VerticalAlignment.Center,
100+
};
101+
102+
var textGraphicOptions = new TextGraphicsOptions
103+
{
104+
GraphicsOptions = new GraphicsOptions
105+
{
106+
Antialias = true
107+
},
108+
TextOptions = new TextOptions
109+
{
110+
HorizontalAlignment = HorizontalAlignment.Center,
111+
VerticalAlignment = VerticalAlignment.Center
112+
}
106113
};
107114

108115
// Apply Banner
@@ -115,8 +122,20 @@ private static IImageProcessingContext DrawWatermark(this IImageProcessingContex
115122
private static IImageProcessingContext DrawBanner(this IImageProcessingContext context, WatermarkSettings settings)
116123
{
117124
var imgSize = context.GetCurrentSize();
118-
119-
var options = new GraphicsOptions(true, PixelColorBlendingMode.Normal, PixelAlphaCompositionMode.SrcOver, 1);
125+
var options = new ShapeGraphicsOptions
126+
{
127+
GraphicsOptions = new GraphicsOptions
128+
{
129+
Antialias = true,
130+
ColorBlendingMode = PixelColorBlendingMode.Normal,
131+
BlendPercentage = 1,
132+
AlphaCompositionMode = PixelAlphaCompositionMode.SrcOver
133+
},
134+
ShapeOptions = new ShapeOptions
135+
{
136+
IntersectionRule = IntersectionRule.Nonzero
137+
}
138+
};
120139

121140
var points = new[] { new PointF(0, imgSize.Height), new PointF(imgSize.Width, imgSize.Height) };
122141

@@ -140,7 +159,7 @@ private static IImageProcessingContext DrawBanner(this IImageProcessingContext c
140159
var fullThickness = (float)(thickness * 2);
141160
var pen = new Pen(brush, fullThickness);
142161
var polygon = new Polygon(new LinearLineSegment(points));
143-
162+
144163
return context.Draw(options, pen, polygon);
145164
}
146165
}

src/Mobile.BuildTools/Generators/Images/ImageResizeGenerator.cs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Newtonsoft.Json;
88
using SixLabors.ImageSharp;
99
using SixLabors.ImageSharp.Processing;
10-
using SixLabors.Primitives;
1110

1211
namespace Mobile.BuildTools.Generators.Images
1312
{

src/Mobile.BuildTools/Mobile.BuildTools.csproj

+7-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
<None Include="*.targets;*.props" Pack="true" Kind="$(PrimaryOutputKind)" />
2626
<None Update="Resources\*" Pack="true" PackagePath="$(PrimaryOutputKind)/resources/%(Filename)%(Extension)" />
2727
<None Update="ReadMe.txt" Pack="true" PackagePath="ReadMe.txt" />
28-
<None Include="../../assets/runtime/*.dll" Pack="true" Kind="$(PrimaryOutputKind)" Visible="false" />
29-
<Reference Include="../../assets/runtime/*.dll" />
3028
</ItemGroup>
3129

3230
<ItemGroup>
@@ -35,6 +33,13 @@
3533
<PackageReference Include="Newtonsoft.Json" PrivateAssets="all" />
3634
<PackageReference Include="NuGet.Build.Packaging" PrivateAssets="all" />
3735
<PackageReference Include="Microsoft.Web.Xdt" PrivateAssets="all" />
36+
<PackageReference Include="SixLabors.ImageSharp" PrivateAssets="all" />
37+
<PackageReference Include="SixLabors.ImageSharp.Drawing" PrivateAssets="all" />
38+
<PackageReference Include="SixLabors.Fonts" PrivateAssets="all" />
39+
<PackageReference Include="System.Buffers" PrivateAssets="all" />
40+
<PackageReference Include="System.Memory" PrivateAssets="all" />
41+
<PackageReference Include="System.Numerics.Vectors" PrivateAssets="all" />
42+
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" PrivateAssets="all" />
3843
</ItemGroup>
3944

4045
</Project>

tests/Mobile.BuildTools.Tests/Fixtures/Drawing/ImageUtilsFixture.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void GeneratesExpectedColor(string input, Color color)
3535
new object[] { "Red", Color.Red },
3636
new object[] { "Blue", Color.Blue },
3737
new object[] { "OrangeRed", Color.OrangeRed },
38-
new object[] { "#FF88DD", Color.FromHex("#FF88DD") },
38+
new object[] { "#FF88DD", Color.ParseHex("#FF88DD") },
3939
};
4040
}
4141
}

tests/Mobile.BuildTools.Tests/Mobile.BuildTools.Tests.csproj

+10-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@
1919
CopyToOutputDirectory="PreserveNewest"
2020
Visible="false" />
2121
<EmbeddedResource Include="resources\*" />
22-
<Reference Include="../../assets/runtime/*.dll" />
22+
</ItemGroup>
23+
24+
<ItemGroup>
25+
<PackageReference Include="SixLabors.ImageSharp" GeneratePathProperty="true" PrivateAssets="all" />
26+
<PackageReference Include="SixLabors.ImageSharp.Drawing" GeneratePathProperty="true" PrivateAssets="all" />
27+
<PackageReference Include="SixLabors.Fonts" GeneratePathProperty="true" PrivateAssets="all" />
28+
<PackageReference Include="System.Buffers" GeneratePathProperty="true" PrivateAssets="all" />
29+
<PackageReference Include="System.Memory" GeneratePathProperty="true" PrivateAssets="all" />
30+
<PackageReference Include="System.Numerics.Vectors" GeneratePathProperty="true" PrivateAssets="all" />
31+
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" GeneratePathProperty="true" PrivateAssets="all" />
2332
</ItemGroup>
2433

2534
<ItemGroup>

0 commit comments

Comments
 (0)