Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mattleibow committed Apr 2, 2024
1 parent 49676d2 commit 2d16298
Show file tree
Hide file tree
Showing 17 changed files with 96 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ updates:
- dependency-name: "Microsoft.DotNet.XHarness*" # maestro
- dependency-name: "Svg.*" # needs to be done manually because it relies on a specific verion of Fizzler
- dependency-name: "Fizzler" # needs to be done manually because it is specific to the Svg.* version
- dependency-name: "ExCSS" # needs to be done manually because it is specific to the Svg.* version
- dependency-name: "SkiaSharp*" # needs to be done manually with maui graphics
- dependency-name: "HarfBuzzSharp*" # needs to be done manually with maui graphics
- dependency-name: "Newtonsoft.Json" # needs to be done manually to match VS
Expand Down
4 changes: 4 additions & 0 deletions eng/NuGetVersions.targets
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@
Update="Fizzler"
Version="$(FizzlerPackageVersion)"
/>
<PackageReference
Update="ExCSS"
Version="$(ExCSSPackageVersion)"
/>
<PackageReference
Update="MemoryAnalyzers"
Version="0.1.0-beta.5"
Expand Down
6 changes: 4 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>9.0.0-prerelease.24178.1</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
<MicrosoftDotNetXHarnessCLIVersion>9.0.0-prerelease.24178.1</MicrosoftDotNetXHarnessCLIVersion>
<TizenUIExtensionsVersion>0.9.2</TizenUIExtensionsVersion>
<SvgSkiaPackageVersion>0.5.13</SvgSkiaPackageVersion>
<FizzlerPackageVersion>1.2.0</FizzlerPackageVersion>
<SvgSkiaPackageVersion>1.0.0.16</SvgSkiaPackageVersion>
<FizzlerPackageVersion>1.3.0</FizzlerPackageVersion>
<TizenUIExtensionsVersion>0.9.0</TizenUIExtensionsVersion>
<ExCSSPackageVersion>4.2.3</ExCSSPackageVersion>
<MicrosoftDotNetBuildTasksFeedVersion>8.0.0-beta.24113.2</MicrosoftDotNetBuildTasksFeedVersion>
</PropertyGroup>
<PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions eng/automation/SignList.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<ThirdParty Include="Svg.*.dll" />
<ThirdParty Include="ShimSkiaSharp.dll" />
<ThirdParty Include="Fizzler.dll" />
<ThirdParty Include="ExCSS.dll" />
<ThirdParty Include="Newtonsoft.Json.dll;" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<PackageReference Include="Svg.Model" GeneratePathProperty="true" PrivateAssets="all" />
<PackageReference Include="ShimSkiaSharp" GeneratePathProperty="true" PrivateAssets="all" />
<PackageReference Include="Fizzler" GeneratePathProperty="true" PrivateAssets="all" />
<PackageReference Include="ExCSS" GeneratePathProperty="true" PrivateAssets="all" />
<!-- build task dependencies -->
<PackageReference Include="System.Memory" GeneratePathProperty="true" PrivateAssets="all" />
<PackageReference Include="System.Buffers" GeneratePathProperty="true" PrivateAssets="all" />
Expand All @@ -43,6 +44,7 @@
<_ResizetizerFiles Include="$(PkgShimSkiaSharp)\lib\netstandard2.0\ShimSkiaSharp.dll" />
<_ResizetizerFiles Include="$(PkgSvg_Skia)\lib\netstandard2.0\Svg.Skia.dll" />
<_ResizetizerFiles Include="$(PkgFizzler)\lib\netstandard2.0\Fizzler.dll" />
<_ResizetizerFiles Include="$(PkgExCSS)\lib\netstandard2.0\ExCSS.dll" />
<_ResizetizerFiles Include="$(PkgSystem_IO_UnmanagedMemoryStream)\lib\netstandard1.3\System.IO.UnmanagedMemoryStream.dll" />
<_ResizetizerFiles Include="$(PkgSkiaSharp)\lib\net462\SkiaSharp.dll" />
<_ResizetizerFiles Include="$(PkgSkiaSharp)\lib\net462\SkiaSharp.pdb" />
Expand Down
19 changes: 16 additions & 3 deletions src/SingleProject/Resizetizer/test/UnitTests/BaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,22 @@ void AssertFileMatchesReal(string actualFilename, object[] args = null, [CallerM

var isSimilar = similarity.ErrorPixelPercentage <= ImageErrorThreshold;

Assert.True(
isSimilar,
$"Image was not equal. Error was {similarity.ErrorPixelPercentage}% ({similarity.AbsoluteError} pixels)");
if (!isSimilar)
{
var maskFilename = Path.Combine(DestinationDirectory, GetTestImageFileName(args, methodName));
maskFilename = Path.ChangeExtension(maskFilename, ".mask.png");

Directory.CreateDirectory(Path.GetDirectoryName(maskFilename));

using var mask = SKPixelComparer.GenerateDifferenceMask(actual, expected);
using var data = mask.Encode(SKEncodedImageFormat.Png, 100);
using var maskFile = File.Create(maskFilename);
data.SaveTo(maskFile);

Assert.True(
isSimilar,
$"Image was not equal. Error was {similarity.ErrorPixelPercentage}% ({similarity.AbsoluteError} pixels). See {maskFilename}");
}
}

void SaveImageResultFileReal(string destinationFilename, object[] args = null, [CallerMemberName] string methodName = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,8 @@ public void DiffPropoprtionWithoutBase()
var success = task.Execute();
Assert.True(success, LogErrorEvents.FirstOrDefault()?.Message);

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

AssertFileMatches($"drawable-mdpi/dotnet_bot.png", new object[] { "mdpi" });
AssertFileMatches($"drawable-xhdpi/dotnet_bot.png", new object[] { "xhdpi" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,68 @@ public void ColorsInCssCanBeUsed()
Assert.Equal(SKColors.Empty, pixmap.GetPixelColor(2, 2));
Assert.Equal(0xFF71559B, pixmap.GetPixelColor(2, 6));
}

[Fact]
public void SvgImageWithDecodingIssue_15442()
{
var info = new ResizeImageInfo();
info.Filename = "images/find_icon.svg";
var tools = new SkiaSharpSvgTools(info, Logger);
var dpiPath = new DpiPath("", 1);

tools.Resize(dpiPath, DestinationFilename);

using var resultImage = SKBitmap.Decode(DestinationFilename);
Assert.Equal(200, resultImage.Width);
Assert.Equal(200, resultImage.Height);

using (var image = SKImage.FromBitmap(resultImage))
using (var data = image.Encode(SKEncodedImageFormat.Png, 100))
using (var stream = File.OpenWrite("images/find_icon.svg.png"))
{
data.SaveTo(stream);
}

using var pixmap = resultImage.PeekPixels();

Assert.Equal((SKColor)0x00000000, pixmap.GetPixelColor(10, 10));
Assert.Equal((SKColor)0xFFA5ADF6, pixmap.GetPixelColor(81, 137));
Assert.Equal((SKColor)0xFF635DF7, pixmap.GetPixelColor(125, 137));

Assert.Equal((SKColor)0xFFA5ADF6, pixmap.GetPixelColor(22, 62));
Assert.Equal((SKColor)0xFFA5ADF6, pixmap.GetPixelColor(72, 109));
Assert.Equal((SKColor)0xFFA5ADF6, pixmap.GetPixelColor(131, 23));
Assert.Equal((SKColor)0xFFA5ADF6, pixmap.GetPixelColor(178, 153));
Assert.Equal((SKColor)0xFFA5ADF6, pixmap.GetPixelColor(124, 180));
}

[Fact]
public void SvgImageWithDecodingIssue_12109()
{
var info = new ResizeImageInfo();
info.Filename = "images/warning.svg";
var tools = new SkiaSharpSvgTools(info, Logger);
var dpiPath = new DpiPath("", 1);

tools.Resize(dpiPath, DestinationFilename);

using var resultImage = SKBitmap.Decode(DestinationFilename);
Assert.Equal(42, resultImage.Width);
Assert.Equal(37, resultImage.Height);

using (var image = SKImage.FromBitmap(resultImage))
using (var data = image.Encode(SKEncodedImageFormat.Png, 100))
using (var stream = File.OpenWrite("images/warning.svg.png"))
{
data.SaveTo(stream);
}

using var pixmap = resultImage.PeekPixels();

Assert.Equal((SKColor)0x00000000, pixmap.GetPixelColor(10, 10));
Assert.Equal((SKColor)0xffe26b00, pixmap.GetPixelColor(20, 3));
Assert.Equal((SKColor)0xffe26b00, pixmap.GetPixelColor(20, 34));
}
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2d16298

Please sign in to comment.