Skip to content

Commit

Permalink
Fix MauiIcon ForegroundScale on systems with comma as decimal separat…
Browse files Browse the repository at this point in the history
…or (#11690)

### Description of Change

Specifying the `ForegroundScale` with a dot caused an issue on systems
with commas as decimal separators. The image got upscaled instead of
downscaled on those systems because the `ForegroundScale` was parsed
without passing `InvariantCulture` as culture info. Because of this, the
existing implementation only worked on systems with a dot as a decimal
separator.

In order to solve the issue, the InvariantCulture get's now used when
parsing `ForegroundScale`

Fixes #11685
  • Loading branch information
mattleibow authored Nov 28, 2022
2 parents 123fc7b + 269dcf6 commit ab534a2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/SingleProject/Resizetizer/src/ResizeImageInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using Microsoft.Build.Framework;
using SkiaSharp;
Expand Down Expand Up @@ -95,7 +96,7 @@ public static List<ResizeImageInfo> Parse(IEnumerable<ITaskItem> images)
if (bool.TryParse(image.GetMetadata("IsAppIcon"), out var iai))
info.IsAppIcon = iai;

if (float.TryParse(image.GetMetadata("ForegroundScale"), out var fsc))
if (float.TryParse(image.GetMetadata("ForegroundScale"), NumberStyles.Number, CultureInfo.InvariantCulture, out var fsc))
info.ForegroundScale = fsc;

var fgFile = image.GetMetadata("ForegroundFile");
Expand Down

0 comments on commit ab534a2

Please sign in to comment.