Skip to content

Commit 7120a04

Browse files
committed
Constrain images to a minimum of 1px for width and height
1 parent 848da52 commit 7120a04

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

AssetGenerator/AndroidAssetGenerator.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ public async Task CreateAsset(string filepath, string filename, string destinati
2626
try
2727
{
2828
var name = Enum.GetName(typeof(AndroidResourceType), resourceType.Key);
29-
var resourceDirectoryName = $"drawable-{name.ToLowerInvariant()}-{postfix}";
29+
var resourceDirectoryName = string.IsNullOrEmpty(postfix)
30+
? $"drawable-{name.ToLowerInvariant()}"
31+
: $"drawable-{name.ToLowerInvariant()}-{postfix}";
3032
var svg = new SKSvg();
3133
try
3234
{
@@ -42,6 +44,13 @@ public async Task CreateAsset(string filepath, string filename, string destinati
4244

4345
var width = (int) (svg.CanvasSize.Width * resourceType.Value);
4446
var height = (int) (svg.CanvasSize.Height * resourceType.Value);
47+
48+
// Cheap clamp
49+
if (width < 1)
50+
width = 1;
51+
if (height < 1)
52+
height = 1;
53+
4554
var filenameWithExtension = $"{filename}.png";
4655
var resourceDir = Path.Combine(destinationDirectory, resourceDirectoryName);
4756
if (!Directory.Exists(resourceDir))

0 commit comments

Comments
 (0)