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

时间:2015-07-31 18:58:06

标签: windows-phone-8 windows-runtime windows-phone-8.1 windows-phone win-universal-app

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

1 个答案:

答案 0 :(得分:1)

这就是我解决它的方法。我正在使用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准则。