diff --git a/doc/uno-resizetizer-properties.md b/doc/uno-resizetizer-properties.md index e3d6c9fd..6d8fff76 100644 --- a/doc/uno-resizetizer-properties.md +++ b/doc/uno-resizetizer-properties.md @@ -26,16 +26,17 @@ Properties that can be used across all items ## UnoIcon -| Property Name | Description | -|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------| -| `Include` | Used to insert the path of the Background image. | -| `ForegroundFile` | Used to insert the path of the Foreground image | -| `ForegroundScale` | Used to rescale the Foreground image, in order to fit on the app icon, it's a percentage value so `0.33` will be translated as 33%. | -| `AndroidForegroundScale` | The same as ForegroundScale, but the value will be applied just for Android. | -| `WasmForegroundScale` | The same as ForegroundScale, but the value will be applied just for Wasm | -| `WindowsForegroundScale` | The same as ForegroundScale, but the value will be applied just for Windows | -| `IOSForegroundScale` | The same as ForegroundScale, but the value will be applied just for iOS | -| `SkiaForegroundScale` | The same as ForegroundScale, but the value will be applied just for Skia targets | +| Property Name | Description | +|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------| +| `Include` | Used to insert the path of the Background image. | +| `ForegroundFile` | Used to insert the path of the Foreground image | +| `ForegroundScale` | Used to rescale the Foreground image, in order to fit on the app icon, it's a percentage value so `0.33` will be translated as 33%. | +| `UseBackgroundFile` | If set to `false`, only the foreground image will be used with a transparent background. Defaults to `true` on desktop, `false` elsewhere. | +| `AndroidForegroundScale` | The same as ForegroundScale, but the value will be applied just for Android. | +| `WasmForegroundScale` | The same as ForegroundScale, but the value will be applied just for Wasm | +| `WindowsForegroundScale` | The same as ForegroundScale, but the value will be applied just for Windows | +| `IOSForegroundScale` | The same as ForegroundScale, but the value will be applied just for iOS | +| `SkiaForegroundScale` | The same as ForegroundScale, but the value will be applied just for Skia targets | > [!NOTE] > The `ForegroundScale` (`AndroidForegroundScale`, `WasmForegroundScale`, etc) will override the global `ForegroundScale` value. diff --git a/doc/using-uno-resizetizer.md b/doc/using-uno-resizetizer.md index c92c549b..245070cb 100644 --- a/doc/using-uno-resizetizer.md +++ b/doc/using-uno-resizetizer.md @@ -109,6 +109,7 @@ The Uno Platform SDK exposes several properties that simplify the customization * `UnoIconForegroundFile`: Sets the foreground image file for the icon. * `UnoIconForegroundScale`: Adjusts the scaling of the icon's foreground. * `UnoIconBackgroundColor`: Sets the background color of the icon. +* `UnoUseIconBackgroundFile`: Controls whether the background file is used (useful for platforms where icons can have transparent background, e.g. desktop). For basic adjustments, such as changing the icon's foreground color or applying a common modification across platforms, you can use SDK properties: @@ -362,6 +363,7 @@ Next, some adjustments are needed on `Android`, `Windows`, and `iOS`. ----- ## Platform-Specific Customization + The Uno Resizetizer SDK allows for detailed control over how assets are rendered on different platforms. This can be particularly useful for properties such as icon and splash screen backgrounds, which may need to vary between platforms due to design or visibility concerns. ### Customizing Background Colors Per Platform @@ -382,7 +384,7 @@ For properties like BackgroundColor, which might need different values per platf ``` This setup demonstrates setting a default background color that is overridden on specific platforms. Adjust the conditions to match your project's target frameworks as defined in your project files or SDK documentation. -#### Applying Platform-Specific Scale +### Applying Platform-Specific Scale Similarly, if you want to apply different scaling factors for the icon foreground across platforms, use the platform-specific properties: ```xml diff --git a/src/Resizetizer/src/ResizeImageInfo.cs b/src/Resizetizer/src/ResizeImageInfo.cs index a3e9de06..ccf50e86 100644 --- a/src/Resizetizer/src/ResizeImageInfo.cs +++ b/src/Resizetizer/src/ResizeImageInfo.cs @@ -50,6 +50,8 @@ internal class ResizeImageInfo public bool IsAppIcon { get; set; } + public bool UseBackgroundFile { get; set; } = true; + public bool IsSplashScreen { get; set; } public string? ForegroundFilename { get; set; } @@ -138,6 +140,11 @@ public static List Parse(IEnumerable? images) info.ForegroundScale = fsc; } + if (bool.TryParse(image.GetMetadata(nameof(UseBackgroundFile)), out var uib)) + { + info.UseBackgroundFile = uib; + } + if (info.IsSplashScreen) { SetPlatformForegroundScale(image, "Scale", info); @@ -154,6 +161,12 @@ public static List Parse(IEnumerable? images) } info.ForegroundFilename = fgFileInfo.FullName; + + // If we don't want to apply icon background, we set it to null. + if (!info.UseBackgroundFile) + { + info.Filename = null; + } } if (info.IsAppIcon)