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

Allow to apply Scale on UnoSplashScreen #189

Merged
merged 2 commits into from
Oct 31, 2023
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
10 changes: 8 additions & 2 deletions doc/uno-resizetizer-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,16 @@ Properties that can be used across all items

| Property Name | Description |
| ------------- | ----------- |
| Include | Used to insert the path of the image asset, could be a `png` or `svg` |
| Include | Used to insert the path of the image asset, could be a `png` or `svg`. |

## UnoSplashScreen

| Property Name | Description |
| ------------- | ----------- |
| Include | Used to insert the path of the image asset, could be a `png` or `svg` |
| Include | Used to insert the path of the image asset, could be a `png` or `svg`. |
| Scale | Used to scale the image that will be used as SplashScreen. This property will be override by any platform specific scale. |
| AndroidScale | Used to scale the image that will be used as SplashScreen on Android platform. |
| IOSScale | Used to scale the image that will be used as SplashScreen on iOS platform. |
| WindowsScale | Used to scale the image that will be used as SplashScreen on Windows platform. |
| WasmScale | Used to scale the image that will be used as SplashScreen on Wasm. |
| SkiaScale | Used to scale the image that will be used as SplashScreen on Skia targets (GTK and WPF). |
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<UnoSplashScreen
Include="$(MSBuildThisFileDirectory)Splash\splash_screen.svg"
BaseSize="128,128"
Scale="0.65"
Color="#086AD1" />
</ItemGroup>
</Project>
32 changes: 31 additions & 1 deletion src/Resizetizer/src/ResizeImageInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ public static List<ResizeImageInfo> Parse(IEnumerable<ITaskItem>? images)
info.ForegroundScale = fsc;
}

if (info.IsSplashScreen)
{
SetPlatformForegroundScale(image, "Scale", info);
ApplyPlatformScale(image, info);
}

var fgFile = image.GetMetadata("ForegroundFile");
if (!string.IsNullOrEmpty(fgFile))
{
Expand All @@ -162,6 +168,7 @@ public static List<ResizeImageInfo> Parse(IEnumerable<ITaskItem>? images)
ApplyPlatformForegroundScale(image, info);
}


// TODO:
// - Parse out custom DPI's

Expand All @@ -180,7 +187,6 @@ static void SetPlatformForegroundScale(ITaskItem image, string property, ResizeI
}
}


static void ApplyPlatformForegroundScale(ITaskItem image, ResizeImageInfo info)
{
switch (ResizetizeImages_v0.TargetPlatform)
Expand All @@ -203,5 +209,29 @@ static void ApplyPlatformForegroundScale(ITaskItem image, ResizeImageInfo info)
break;
}
}


static void ApplyPlatformScale(ITaskItem image, ResizeImageInfo info)
{
switch (ResizetizeImages_v0.TargetPlatform)
{
case "android":
SetPlatformForegroundScale(image, "AndroidScale", info);
break;
case "ios":
SetPlatformForegroundScale(image, "IOSScale", info);
break;
case "uwp":
SetPlatformForegroundScale(image, "WindowsScale", info);
break;
case "wasm":
SetPlatformForegroundScale(image, "WasmScale", info);
break;
//skia
case "netstandard" or "wpf":
SetPlatformForegroundScale(image, "SkiaScale", info);
break;
}
}
}
}
2 changes: 1 addition & 1 deletion src/Resizetizer/src/Resizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public ResizedImageInfo Resize(DpiPath dpi, string inputsFile)
void Rasterize(DpiPath dpi, string destination)
{
tools ??= SkiaSharpTools.Create(Info.IsVector, Info.Filename, Info.BaseSize, Info.Color, Info.TintColor, Logger);
tools.Resize(dpi, destination);
tools.Resize(dpi, destination, Info.ForegroundScale);
}
}
}
Loading