mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
Reduce the size of keyboard.png
This commit is contained in:
parent
106984e9c7
commit
fe62cbd357
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 |
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user