cmd/gio: add support for iOS App Store icons

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-08-16 12:32:53 +02:00
parent 50599bc65d
commit c4e46e0348
3 changed files with 17 additions and 8 deletions
+4 -4
View File
@@ -246,10 +246,10 @@ func exeAndroid(tmpDir string, tools *androidTools, bi *buildInfo) (err error) {
iconSnip := ""
if _, err := os.Stat(icon); err == nil {
err := buildIcons(resDir, icon, []iconVariant{
{filepath.Join("mipmap-hdpi", "ic_launcher.png"), 72},
{filepath.Join("mipmap-xhdpi", "ic_launcher.png"), 96},
{filepath.Join("mipmap-xxhdpi", "ic_launcher.png"), 144},
{filepath.Join("mipmap-xxxhdpi", "ic_launcher.png"), 192},
{path: filepath.Join("mipmap-hdpi", "ic_launcher.png"), size: 72},
{path: filepath.Join("mipmap-xhdpi", "ic_launcher.png"), size: 96},
{path: filepath.Join("mipmap-xxhdpi", "ic_launcher.png"), size: 144},
{path: filepath.Join("mipmap-xxxhdpi", "ic_launcher.png"), size: 192},
})
if err != nil {
return err
+8 -1
View File
@@ -7,6 +7,7 @@ import (
"flag"
"fmt"
"image"
"image/color"
"image/png"
"io"
"io/ioutil"
@@ -204,6 +205,7 @@ var allArchs = map[string]arch{
type iconVariant struct {
path string
size int
fill bool
}
func buildIcons(baseDir, icon string, variants []iconVariant) error {
@@ -221,7 +223,12 @@ func buildIcons(baseDir, icon string, variants []iconVariant) error {
v := v
resizes.Go(func() (err error) {
scaled := image.NewNRGBA(image.Rectangle{Max: image.Point{X: v.size, Y: v.size}})
draw.CatmullRom.Scale(scaled, scaled.Bounds(), img, img.Bounds(), draw.Src, nil)
op := draw.Src
if v.fill {
op = draw.Over
draw.Draw(scaled, scaled.Bounds(), &image.Uniform{color.White}, image.Point{}, draw.Src)
}
draw.CatmullRom.Scale(scaled, scaled.Bounds(), img, img.Bounds(), op, nil)
path := filepath.Join(baseDir, v.path)
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
return err
+5 -3
View File
@@ -232,9 +232,11 @@ func iosIcons(bi *buildInfo, tmpDir, appDir, icon string) (string, error) {
}
appIcon := filepath.Join(assets, "AppIcon.appiconset")
err := buildIcons(appIcon, icon, []iconVariant{
{"ios_2x.png", 120},
{"ios_3x.png", 180},
{"ios_store.png", 1024},
{path: "ios_2x.png", size: 120},
{path: "ios_3x.png", size: 180},
// The App Store icon is not allowed to contain
// transparent pixels.
{path: "ios_store.png", size: 1024, fill: true},
})
if err != nil {
return "", err