Skip to content

Commit

Permalink
Merge pull request #189 from unoplatform/pj/scale-splash-image
Browse files Browse the repository at this point in the history
Allow to apply Scale on UnoSplashScreen
  • Loading branch information
nickrandolph authored Oct 31, 2023
2 parents 552eeb6 + 6670156 commit 39a8a1b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
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);
}
}
}

0 comments on commit 39a8a1b

Please sign in to comment.