如何最简单地为不同分辨率的图块、闪屏等生成位图?

How do easiest I generate bitmaps for tiles, splash screen etc in different resolutions?

在 Windows 8/10/Phone 项目中,您应该以不同的分辨率为磁贴、启动画面和商店徽标提供资源。我有一个基于矢量的图标。我能否以某种方式从中生成我需要的所有内容而无需手动执行所有操作?

我就是这样解决的。我使用 Inkscape 绘制图标,使用 InkscapeBatch (http://inkscapebatch.org/) 生成位图。为此,我有三个版本的图标:

  • logo.svg – 尺寸 36x36。用于大多数瓷砖。
  • logo_high.svg – 尺寸 36x60。用于 Windows Phone.
  • 中的启动画面
  • logo_wide.svg – 尺寸 74.4x36。用于初始屏幕和宽磁贴。

只要比例合适,文档大小并不重要。

在与 svg 文件相同的文件夹中,我有一个正在发挥作用的 InkscapeBatch 文件 (.idp)。

我在 Inkscape 的绘图中使用了黑色。当我在下面的脚本中使用命令 Replace fill:#000000;fill-opacity:1; fill:#FFFFFF;fill-opacity:1; 生成位图时,我将黑色替换为白色。

这些是我正在使用的脚本。请注意,这些脚本会生成您可能不需要的所有分辨率和大小的位图。另请注意,我使用的文件名与原始文件名略有不同。

Windows 8.1

PathClear true
FileFormat png
FilePrefix
ExportBackground

// Convert
PathExport '.\windowsstore'

ExportArea canvas
FileSvg '.\logo.svg'

// Replace black color with white color
Replace fill:#000000;fill-opacity:1; fill:#FFFFFF;fill-opacity:1;



FileName 'LogoSquare30x30.targetsize-16'
ExportWidth 16
ExportHeight 16
Convert

FileName 'LogoSquare30x30.targetsize-32'
ExportWidth 32
ExportHeight 32
Convert

FileName 'LogoSquare30x30.targetsize-48'
ExportWidth 48
ExportHeight 48
Convert

FileName 'LogoSquare30x30.targetsize-256'
ExportWidth 256
ExportHeight 256
Convert

FileName 'LogoSquare30x30.scale-80'
ExportWidth 24
ExportHeight 24
Convert

FileName 'LogoSquare30x30.scale-100'
ExportWidth 30
ExportHeight 30
Convert

FileName 'LogoSquare30x30.scale-140'
ExportWidth 42
ExportHeight 42
Convert

FileName 'LogoSquare30x30.scale-180'
ExportWidth 54
ExportHeight 54
Convert



FileName 'LogoSquare70x70.scale-80'
ExportWidth 56
ExportHeight 56
Convert

FileName 'LogoSquare70x70.scale-100'
ExportWidth 70
ExportHeight 70
Convert

FileName 'LogoSquare70x70.scale-140'
ExportWidth 98
ExportHeight 98
Convert

FileName 'LogoSquare70x70.scale-180'
ExportWidth 126
ExportHeight 126
Convert



FileName 'LogoSquare150x150.scale-80'
ExportWidth 120
ExportHeight 120
Convert

FileName 'LogoSquare150x150.scale-100'
ExportWidth 150
ExportHeight 150
Convert

FileName 'LogoSquare150x150.scale-140'
ExportWidth 210
ExportHeight 210
Convert

FileName 'LogoSquare150x150.scale-180'
ExportWidth 270
ExportHeight 270
Convert



FileName 'LogoSquare310x310.scale-80'
ExportWidth 248
ExportHeight 248
Convert

FileName 'LogoSquare310x310.scale-100'
ExportWidth 310
ExportHeight 310
Convert

FileName 'LogoSquare310x310.scale-140'
ExportWidth 434
ExportHeight 434
Convert

FileName 'LogoSquare310x310.scale-180'
ExportWidth 558
ExportHeight 558
Convert



FileName 'StoreLogo.scale-100'
ExportWidth 50
ExportHeight 50
Convert

FileName 'StoreLogo.scale-140'
ExportWidth 70
ExportHeight 70
Convert

FileName 'StoreLogo.scale-180'
ExportWidth 90
ExportHeight 90
Convert



FileSvg '.\logo_wide.svg'

// Replace black color with white color
Replace fill:#000000;fill-opacity:1; fill:#FFFFFF;fill-opacity:1;



FileName 'LogoWide310x150.scale-80'
ExportWidth 248
ExportHeight 120
Convert

FileName 'LogoWide310x150.scale-100'
ExportWidth 310
ExportHeight 150
Convert

FileName 'LogoWide310x150.scale-140'
ExportWidth 434
ExportHeight 210
Convert

FileName 'LogoWide310x150.scale-180'
ExportWidth 558
ExportHeight 270
Convert



FileName 'SplashScreen.scale-100'
ExportWidth 620
ExportHeight 300
Convert

FileName 'SplashScreen.scale-140'
ExportWidth 868
ExportHeight 420
Convert

FileName 'SplashScreen.scale-180'
ExportWidth 1116
ExportHeight 540
Convert

Windows Phone 8.1

PathClear true
FileFormat png
FilePrefix
ExportBackground

// Convert
PathExport '.\windowsphone'

ExportArea canvas
FileSvg '.\logo.svg'

// Replace black color with white color
Replace fill:#000000;fill-opacity:1; fill:#FFFFFF;fill-opacity:1;



FileName 'LogoSquare44x44.scale-100'
ExportWidth 44
ExportHeight 44
Convert

FileName 'LogoSquare44x44.scale-140'
ExportWidth 62
ExportHeight 62
Convert

FileName 'LogoSquare44x44.scale-240'
ExportWidth 106
ExportHeight 106
Convert



FileName 'LogoSquare71x71.scale-100'
ExportWidth 71
ExportHeight 71
Convert

FileName 'LogoSquare71x71.scale-140'
ExportWidth 99
ExportHeight 99
Convert

FileName 'LogoSquare71x71.scale-240'
ExportWidth 170
ExportHeight 170
Convert



FileName 'LogoSquare150x150.scale-100'
ExportWidth 150
ExportHeight 150
Convert

FileName 'LogoSquare150x150.scale-140'
ExportWidth 210
ExportHeight 210
Convert

FileName 'LogoSquare150x150.scale-240'
ExportWidth 360
ExportHeight 360
Convert



FileName 'StoreLogo.scale-100'
ExportWidth 50
ExportHeight 50
Convert

FileName 'StoreLogo.scale-140'
ExportWidth 70
ExportHeight 70
Convert

FileName 'StoreLogo.scale-240'
ExportWidth 120
ExportHeight 120
Convert



FileSvg '.\logo_wide.svg'

// Replace black color with white color
Replace fill:#000000;fill-opacity:1; fill:#FFFFFF;fill-opacity:1;



FileName 'LogoWide310x150.scale-100'
ExportWidth 310
ExportHeight 150
Convert

FileName 'LogoWide310x150.scale-140'
ExportWidth 434
ExportHeight 210
Convert

FileName 'LogoWide310x150.scale-240'
ExportWidth 744
ExportHeight 360
Convert




FileSvg '.\logo_high.svg'

// Replace black color with white color
Replace fill:#000000;fill-opacity:1; fill:#FFFFFF;fill-opacity:1;

// This could be used to add a background color
// ExportBackground #004873 

FileName 'SplashScreen.scale-100'
ExportWidth 480
ExportHeight 800
Convert

FileName 'SplashScreen.scale-140'
ExportWidth 672
ExportHeight 1120
Convert

FileName 'SplashScreen.scale-240'
ExportWidth 1152
ExportHeight 1920
Convert

Windows 10

我在 Github 上发布了 Windows 10 的解决方案:

https://github.com/pekspro/Icons-and-tiles-generator

这与上面 Windows 8.1 的解决方案非常相似,但有一些模板可以开始。这些应遵循 Microsoft 准则。