Skip to content

Commit ddc3bd5

Browse files
committed
Squashed commit of the following:
commit c59c1281218105b85c83435855c241a86315fce1 Merge: 0c28a1b 49676d2 Author: Matthew Leibowitz <[email protected]> Date: Tue Apr 2 19:08:33 2024 +0200 Merge branch 'main' into dev--moljac--fix-resizetizer-invalid-png-from-svg commit 0c28a1b Merge: 13ee3c8 e0b85ca Author: moljac <[email protected]> Date: Wed Mar 20 18:58:22 2024 +0100 Merge branch 'main' into dev--moljac--fix-resizetizer-invalid-png-from-svg commit 13ee3c8 Author: moljac <[email protected]> Date: Fri Mar 15 17:59:23 2024 +0100 fixes for obsolete classes commit 9dd7bfe Author: moljac <[email protected]> Date: Fri Mar 15 09:52:51 2024 +0100 Svg.Skia bumped to 1.0.0.16 that has netstandard2.0 package commit e45d3cf Author: moljac <[email protected]> Date: Thu Mar 14 20:18:55 2024 +0100 downgrade Svg.Skia commit f1c8b3d Author: moljac <[email protected]> Date: Wed Mar 13 18:56:06 2024 +0100 Update Versions.props commit e663e62 Merge: 4cfef26 289b6c2 Author: moljac <[email protected]> Date: Wed Mar 13 15:40:49 2024 +0100 Merge branch 'main' into dev--moljac--fix-resizetizer-invalid-png-from-svg commit 4cfef26 Author: moljac <[email protected]> Date: Wed Mar 6 15:23:49 2024 +0100 downgrade because of removed netstandard2.0 TFM commit 7b9d04c Author: moljac <[email protected]> Date: Mon Mar 4 21:33:33 2024 +0100 bumped SvgSkia and ExCSS again commit 3c9ff0a Merge: 0b688bb 126f47a Author: moljac <[email protected]> Date: Mon Mar 4 20:26:58 2024 +0100 Merge branch 'main' into dev--moljac--fix-resizetizer-invalid-png-from-svg commit 0b688bb Merge: 35febc9 6ec214f Author: moljac <[email protected]> Date: Tue Nov 14 10:49:50 2023 +0100 Merge branch 'main' into dev--moljac--fix-resizetizer-invalid-png-from-svg commit 35febc9 Merge: b5666d6 b414925 Author: moljac <[email protected]> Date: Wed Nov 8 22:33:58 2023 +0100 Merge branch 'main' into dev--moljac--fix-resizetizer-invalid-png-from-svg commit b5666d6 Author: moljac <[email protected]> Date: Wed Nov 8 16:33:04 2023 +0100 reverted case sensitive filename fix commit 6de2948 Merge: b321b9a b170fbb Author: moljac <[email protected]> Date: Wed Nov 8 15:35:25 2023 +0100 Merge branch 'main' into dev--moljac--fix-resizetizer-invalid-png-from-svg commit b321b9a Author: moljac <[email protected]> Date: Wed Nov 8 15:07:31 2023 +0100 workarounds for unit tests (off by 1 pixel errors) commit acaed1d Author: moljac <[email protected]> Date: Tue Nov 7 17:04:42 2023 +0100 another pixel assert fixed commit 4978ea3 Author: moljac <[email protected]> Date: Tue Nov 7 17:01:56 2023 +0100 skColor for pixel assert added commit e9966c6 Author: moljac <[email protected]> Date: Tue Nov 7 16:57:58 2023 +0100 reverting assert commit 92a50e6 Author: moljac <[email protected]> Date: Tue Nov 7 09:36:16 2023 +0100 more assert workarounds commit 3084e77 Author: moljac <[email protected]> Date: Tue Nov 7 08:06:09 2023 +0100 another assert fixed commit 50d2c98 Merge: 4dea747 c02a670 Author: moljac <[email protected]> Date: Tue Nov 7 08:05:49 2023 +0100 Merge branch 'main' into dev--moljac--fix-resizetizer-invalid-png-from-svg commit 4dea747 Merge: f53c953 7b06dba Author: moljac <[email protected]> Date: Mon Nov 6 21:39:05 2023 +0100 Merge branch 'main' into dev--moljac--fix-resizetizer-invalid-png-from-svg commit f53c953 Author: moljac <[email protected]> Date: Mon Nov 6 21:36:01 2023 +0100 assert fix commit 90ce477 Merge: d5a152d 7be95d4 Author: moljac <[email protected]> Date: Mon Nov 6 20:26:11 2023 +0100 Merge branch 'main' into dev--moljac--fix-resizetizer-invalid-png-from-svg commit d5a152d Author: moljac <[email protected]> Date: Mon Nov 6 20:25:34 2023 +0100 fix casesensitivity commit 16187d3 Author: moljac <[email protected]> Date: Sun Nov 5 09:40:45 2023 +0100 downgrade ExCSSPackageVersion commit f2ae325 Merge: 6413516 a5f717b Author: moljac <[email protected]> Date: Sat Nov 4 14:25:26 2023 +0100 Merge branch 'main' into dev--moljac--fix-resizetizer-invalid-png-from-svg commit 6413516 Author: moljac <[email protected]> Date: Tue Oct 31 16:49:07 2023 +0100 Update Resizetizer.UnitTests.csproj commit e59d443 Author: moljac <[email protected]> Date: Tue Oct 31 16:48:32 2023 +0100 bumped versions for assembly references which were causing CI failures commit 3b328ec Merge: 065f9bf a589b12 Author: moljac <[email protected]> Date: Tue Oct 31 11:10:12 2023 +0100 Merge branch 'main' into dev--moljac--fix-resizetizer-invalid-png-from-svg commit 065f9bf Author: moljac <[email protected]> Date: Fri Sep 29 09:12:27 2023 +0200 propert used instead of literal (_SkiaSharpExtendedVersion) commit 289eaed Author: moljac <[email protected]> Date: Fri Sep 29 09:05:15 2023 +0200 reverted to Include instead of Update commit a4c6c78 Author: moljac <[email protected]> Date: Thu Sep 28 17:51:07 2023 +0200 duplicare PackageReference fix commit d0fcdd7 Merge: da2c6e8 9895399 Author: moljac <[email protected]> Date: Wed Sep 27 10:54:24 2023 +0200 Merge branch 'main' into dev--moljac--fix-resizetizer-invalid-png-from-svg commit da2c6e8 Author: moljac <[email protected]> Date: Wed Sep 20 13:05:04 2023 +0200 bumped to newest versions commit 433c12f Author: moljac <[email protected]> Date: Tue Sep 5 21:59:55 2023 +0200 test for issue 15442 commit 4a4f793 Merge: 91292c6 c05b2a0 Author: moljac <[email protected]> Date: Tue Sep 5 12:43:02 2023 +0200 Merge branch 'main' into dev--moljac--fix-resizetizer-invalid-png-from-svg commit 91292c6 Author: moljac <[email protected]> Date: Tue Sep 5 12:40:04 2023 +0200 size fix (error on CI test runs) commit fff5b1b Author: moljac <[email protected]> Date: Tue Sep 5 12:39:45 2023 +0200 nuget bumps commit 1965362 Merge: 97f49de 51c7287 Author: moljac <[email protected]> Date: Tue Aug 8 16:42:06 2023 +0200 Merge branch 'main' into dev--moljac--fix-resizetizer-invalid-png-from-svg commit 97f49de Author: moljac <[email protected]> Date: Thu Jul 13 10:01:27 2023 +0200 updated unit test to reflect png image with issue commit 6c3a7aa Author: Matthew Leibowitz <[email protected]> Date: Wed Jul 12 20:09:58 2023 +0200 I think this is the correct way commit 6490514 Author: moljac <[email protected]> Date: Wed Jul 12 12:05:45 2023 +0200 Added test for SVG image with issue commit dee1995 Author: moljac <[email protected]> Date: Wed Jul 12 10:58:10 2023 +0200 Resizetizer unit tests nugets updates commit de0d510 Author: moljac <[email protected]> Date: Wed Jul 12 10:57:45 2023 +0200 Resizetizer nuget updates commit 8dd6fc8 Author: moljac <[email protected]> Date: Tue Jul 11 20:57:38 2023 +0200 test added commit 6529151 Author: moljac <[email protected]> Date: Tue Jul 11 20:57:29 2023 +0200 Skia.Svg version bumped/updated commit 1faa261 Author: moljac <[email protected]> Date: Tue Jul 11 20:57:14 2023 +0200 Skia.Svg version bumped/updated commit 0abf144 Author: moljac <[email protected]> Date: Tue Jul 11 20:56:56 2023 +0200 new problematic icon added
1 parent 49676d2 commit ddc3bd5

File tree

21 files changed

+96
-7
lines changed

21 files changed

+96
-7
lines changed

.github/dependabot.yml

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ updates:
5151
- dependency-name: "Microsoft.DotNet.XHarness*" # maestro
5252
- dependency-name: "Svg.*" # needs to be done manually because it relies on a specific verion of Fizzler
5353
- dependency-name: "Fizzler" # needs to be done manually because it is specific to the Svg.* version
54+
- dependency-name: "ExCSS" # needs to be done manually because it is specific to the Svg.* version
5455
- dependency-name: "SkiaSharp*" # needs to be done manually with maui graphics
5556
- dependency-name: "HarfBuzzSharp*" # needs to be done manually with maui graphics
5657
- dependency-name: "Newtonsoft.Json" # needs to be done manually to match VS

eng/NuGetVersions.targets

+4
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@
233233
Update="Fizzler"
234234
Version="$(FizzlerPackageVersion)"
235235
/>
236+
<PackageReference
237+
Update="ExCSS"
238+
Version="$(ExCSSPackageVersion)"
239+
/>
236240
<PackageReference
237241
Update="MemoryAnalyzers"
238242
Version="0.1.0-beta.5"

eng/Versions.props

+4-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@
8282
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>9.0.0-prerelease.24178.1</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
8383
<MicrosoftDotNetXHarnessCLIVersion>9.0.0-prerelease.24178.1</MicrosoftDotNetXHarnessCLIVersion>
8484
<TizenUIExtensionsVersion>0.9.2</TizenUIExtensionsVersion>
85-
<SvgSkiaPackageVersion>0.5.13</SvgSkiaPackageVersion>
86-
<FizzlerPackageVersion>1.2.0</FizzlerPackageVersion>
85+
<SvgSkiaPackageVersion>1.0.0.16</SvgSkiaPackageVersion>
86+
<FizzlerPackageVersion>1.3.0</FizzlerPackageVersion>
87+
<TizenUIExtensionsVersion>0.9.0</TizenUIExtensionsVersion>
88+
<ExCSSPackageVersion>4.2.3</ExCSSPackageVersion>
8789
<MicrosoftDotNetBuildTasksFeedVersion>8.0.0-beta.24113.2</MicrosoftDotNetBuildTasksFeedVersion>
8890
</PropertyGroup>
8991
<PropertyGroup>

eng/automation/SignList.xml

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<ThirdParty Include="Svg.*.dll" />
3535
<ThirdParty Include="ShimSkiaSharp.dll" />
3636
<ThirdParty Include="Fizzler.dll" />
37+
<ThirdParty Include="ExCSS.dll" />
3738
<ThirdParty Include="Newtonsoft.Json.dll;" />
3839
</ItemGroup>
3940

Loading
Loading
Loading
Loading

src/SingleProject/Resizetizer/src/ResizetizerPackages.projitems

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<PackageReference Include="Svg.Model" GeneratePathProperty="true" PrivateAssets="all" />
1818
<PackageReference Include="ShimSkiaSharp" GeneratePathProperty="true" PrivateAssets="all" />
1919
<PackageReference Include="Fizzler" GeneratePathProperty="true" PrivateAssets="all" />
20+
<PackageReference Include="ExCSS" GeneratePathProperty="true" PrivateAssets="all" />
2021
<!-- build task dependencies -->
2122
<PackageReference Include="System.Memory" GeneratePathProperty="true" PrivateAssets="all" />
2223
<PackageReference Include="System.Buffers" GeneratePathProperty="true" PrivateAssets="all" />
@@ -43,6 +44,7 @@
4344
<_ResizetizerFiles Include="$(PkgShimSkiaSharp)\lib\netstandard2.0\ShimSkiaSharp.dll" />
4445
<_ResizetizerFiles Include="$(PkgSvg_Skia)\lib\netstandard2.0\Svg.Skia.dll" />
4546
<_ResizetizerFiles Include="$(PkgFizzler)\lib\netstandard2.0\Fizzler.dll" />
47+
<_ResizetizerFiles Include="$(PkgExCSS)\lib\netstandard2.0\ExCSS.dll" />
4648
<_ResizetizerFiles Include="$(PkgSystem_IO_UnmanagedMemoryStream)\lib\netstandard1.3\System.IO.UnmanagedMemoryStream.dll" />
4749
<_ResizetizerFiles Include="$(PkgSkiaSharp)\lib\net462\SkiaSharp.dll" />
4850
<_ResizetizerFiles Include="$(PkgSkiaSharp)\lib\net462\SkiaSharp.pdb" />

src/SingleProject/Resizetizer/test/UnitTests/BaseTest.cs

+16-3
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,22 @@ void AssertFileMatchesReal(string actualFilename, object[] args = null, [CallerM
135135

136136
var isSimilar = similarity.ErrorPixelPercentage <= ImageErrorThreshold;
137137

138-
Assert.True(
139-
isSimilar,
140-
$"Image was not equal. Error was {similarity.ErrorPixelPercentage}% ({similarity.AbsoluteError} pixels)");
138+
if (!isSimilar)
139+
{
140+
var maskFilename = Path.Combine(DestinationDirectory, GetTestImageFileName(args, methodName));
141+
maskFilename = Path.ChangeExtension(maskFilename, ".mask.png");
142+
143+
Directory.CreateDirectory(Path.GetDirectoryName(maskFilename));
144+
145+
using var mask = SKPixelComparer.GenerateDifferenceMask(actual, expected);
146+
using var data = mask.Encode(SKEncodedImageFormat.Png, 100);
147+
using var maskFile = File.Create(maskFilename);
148+
data.SaveTo(maskFile);
149+
150+
Assert.True(
151+
isSimilar,
152+
$"Image was not equal. Error was {similarity.ErrorPixelPercentage}% ({similarity.AbsoluteError} pixels). See {maskFilename}");
153+
}
141154
}
142155

143156
void SaveImageResultFileReal(string destinationFilename, object[] args = null, [CallerMemberName] string methodName = null)

src/SingleProject/Resizetizer/test/UnitTests/ResizetizeImagesTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,8 @@ public void DiffPropoprtionWithoutBase()
778778
var success = task.Execute();
779779
Assert.True(success, LogErrorEvents.FirstOrDefault()?.Message);
780780

781-
AssertFileSize($"drawable-mdpi/dotnet_bot.png", 249, 280);
782-
AssertFileSize($"drawable-xhdpi/dotnet_bot.png", 498, 560);
781+
AssertFileSize($"drawable-mdpi/dotnet_bot.png", 250, 281);
782+
AssertFileSize($"drawable-xhdpi/dotnet_bot.png", 500, 562);
783783

784784
AssertFileMatches($"drawable-mdpi/dotnet_bot.png", new object[] { "mdpi" });
785785
AssertFileMatches($"drawable-xhdpi/dotnet_bot.png", new object[] { "xhdpi" });

src/SingleProject/Resizetizer/test/UnitTests/SkiaSharpSvgToolsTests.cs

+62
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,68 @@ public void ColorsInCssCanBeUsed()
270270
Assert.Equal(SKColors.Empty, pixmap.GetPixelColor(2, 2));
271271
Assert.Equal(0xFF71559B, pixmap.GetPixelColor(2, 6));
272272
}
273+
274+
[Fact]
275+
public void SvgImageWithDecodingIssue_15442()
276+
{
277+
var info = new ResizeImageInfo();
278+
info.Filename = "images/find_icon.svg";
279+
var tools = new SkiaSharpSvgTools(info, Logger);
280+
var dpiPath = new DpiPath("", 1);
281+
282+
tools.Resize(dpiPath, DestinationFilename);
283+
284+
using var resultImage = SKBitmap.Decode(DestinationFilename);
285+
Assert.Equal(200, resultImage.Width);
286+
Assert.Equal(200, resultImage.Height);
287+
288+
using (var image = SKImage.FromBitmap(resultImage))
289+
using (var data = image.Encode(SKEncodedImageFormat.Png, 100))
290+
using (var stream = File.OpenWrite("images/find_icon.svg.png"))
291+
{
292+
data.SaveTo(stream);
293+
}
294+
295+
using var pixmap = resultImage.PeekPixels();
296+
297+
Assert.Equal((SKColor)0x00000000, pixmap.GetPixelColor(10, 10));
298+
Assert.Equal((SKColor)0xFFA5ADF6, pixmap.GetPixelColor(81, 137));
299+
Assert.Equal((SKColor)0xFF635DF7, pixmap.GetPixelColor(125, 137));
300+
301+
Assert.Equal((SKColor)0xFFA5ADF6, pixmap.GetPixelColor(22, 62));
302+
Assert.Equal((SKColor)0xFFA5ADF6, pixmap.GetPixelColor(72, 109));
303+
Assert.Equal((SKColor)0xFFA5ADF6, pixmap.GetPixelColor(131, 23));
304+
Assert.Equal((SKColor)0xFFA5ADF6, pixmap.GetPixelColor(178, 153));
305+
Assert.Equal((SKColor)0xFFA5ADF6, pixmap.GetPixelColor(124, 180));
306+
}
307+
308+
[Fact]
309+
public void SvgImageWithDecodingIssue_12109()
310+
{
311+
var info = new ResizeImageInfo();
312+
info.Filename = "images/warning.svg";
313+
var tools = new SkiaSharpSvgTools(info, Logger);
314+
var dpiPath = new DpiPath("", 1);
315+
316+
tools.Resize(dpiPath, DestinationFilename);
317+
318+
using var resultImage = SKBitmap.Decode(DestinationFilename);
319+
Assert.Equal(42, resultImage.Width);
320+
Assert.Equal(37, resultImage.Height);
321+
322+
using (var image = SKImage.FromBitmap(resultImage))
323+
using (var data = image.Encode(SKEncodedImageFormat.Png, 100))
324+
using (var stream = File.OpenWrite("images/warning.svg.png"))
325+
{
326+
data.SaveTo(stream);
327+
}
328+
329+
using var pixmap = resultImage.PeekPixels();
330+
331+
Assert.Equal((SKColor)0x00000000, pixmap.GetPixelColor(10, 10));
332+
Assert.Equal((SKColor)0xffe26b00, pixmap.GetPixelColor(20, 3));
333+
Assert.Equal((SKColor)0xffe26b00, pixmap.GetPixelColor(20, 34));
334+
}
273335
}
274336
}
275337
}
Loading
Loading

0 commit comments

Comments
 (0)