Fix 4c8f1b0f81: First entry of station cargo filter list was broken. (#13382)
[openttd-github.git] / os / windows / winstore / generate-assets.ps1
blobbd12caf80acfebde5ef16e0ac64a10faff9d471a
1 function ResizeImage() {
2 param([String]$sourcePath, [Int]$targetWidth, [Int]$targetHeight, [String]$targetPath)
4 Add-Type -AssemblyName "System.Drawing"
6 $img = [System.Drawing.Image]::FromFile($sourcePath)
8 $ratioX = $targetWidth / $img.Width;
9 $ratioY = $targetHeight / $img.Height;
11 $ratio = $ratioY
13 if ($ratioX -le $ratioY) {
14 $ratio = $ratioX
17 $newWidth = [int] ($img.Width * $ratio)
18 $newHeight = [int] ($img.Height * $ratio)
20 $resizedImage = New-Object System.Drawing.Bitmap($targetWidth, $targetHeight)
21 $graph = [System.Drawing.Graphics]::FromImage($resizedImage)
22 $graph.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
24 $graph.Clear([System.Drawing.Color]::Transparent)
25 $graph.DrawImage($img, $targetWidth / 2 - $newWidth / 2, $targetHeight / 2 - $newHeight / 2, $newWidth, $newHeight)
27 $resizedImage.Save($targetPath)
28 $resizedImage.Dispose()
29 $img.Dispose()
32 $logoPath = "..\..\..\media\openttd.2048.png"
34 # Create the main image assets required for the Windows Store
35 New-Item -Path "." -Name "assets" -ItemType "directory" -Force
36 ResizeImage $logoPath 1240 1240 "assets\LargeTile.png"
37 ResizeImage $logoPath 284 284 "assets\SmallTile.png"
38 ResizeImage $logoPath 2480 1200 "assets\SplashScreen.png"
39 ResizeImage $logoPath 176 176 "assets\Square44x44Logo.png"
40 Copy-Item "assets\Square44x44Logo.png" -Destination "assets\Square44x44Logo.targetsize-44_altform-unplated.png"
41 ResizeImage $logoPath 600 600 "assets\Square150x150Logo.png"
42 Copy-Item "assets\Square150x150Logo.png" -Destination "assets\Square150x150Logo.targetsize-150_altform-unplated.png"
43 ResizeImage $logoPath 200 200 "assets\StoreLogo.png"
44 ResizeImage $logoPath 1240 600 "assets\Wide310x150Logo.png"
46 # Copy the logo for the store for the common package
47 New-Item -Path "." -Name "assets-common" -ItemType "directory" -Force
48 Copy-Item "assets\StoreLogo.png" -Destination "assets-common\StoreLogoCommon.png"