Reduce the size of keyboard.png

This commit is contained in:
Hajime Hoshi 2015-01-21 01:06:48 +09:00
parent 106984e9c7
commit fe62cbd357
3 changed files with 8 additions and 1 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -22,6 +22,7 @@ import (
einternal "github.com/hajimehoshi/ebiten/internal" einternal "github.com/hajimehoshi/ebiten/internal"
"image" "image"
"image/color" "image/color"
"image/draw"
"image/png" "image/png"
"log" "log"
"os" "os"
@ -103,12 +104,18 @@ func outputKeyboardImage() (map[string]image.Rectangle, error) {
y += height y += height
} }
palette := color.Palette([]color.Color{
color.Transparent, color.Opaque,
})
palettedImg := image.NewPaletted(img.Bounds(), palette)
draw.Draw(palettedImg, palettedImg.Bounds(), img, image.ZP, draw.Src)
f, err := os.Create("images/keyboard/keyboard.png") f, err := os.Create("images/keyboard/keyboard.png")
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer f.Close() defer f.Close()
if err := png.Encode(f, img); err != nil { if err := png.Encode(f, palettedImg); err != nil {
return nil, err return nil, err
} }
return keyMap, nil return keyMap, nil