Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resizetizer issues fixes - nuget bumps #16100

Merged
merged 1 commit into from
Apr 3, 2024
Merged
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
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
Binary file modified src/Controls/tests/UITests/snapshots/android/Issue16094Test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Controls/tests/UITests/snapshots/android/Issue18242Test.png
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.
Binary file modified src/Controls/tests/UITests/snapshots/ios/LoadAndVerifySvg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
Loading