Impl EncodeGray.

This commit is contained in:
Shunsuke Michii 2016-06-29 16:29:38 +09:00
parent 00f04ef2a9
commit 3a78b3d0d3
2 changed files with 86 additions and 0 deletions

View file

@ -4,6 +4,7 @@ import (
"bufio"
"fmt"
"image"
"image/color"
"os"
"testing"
@ -217,3 +218,27 @@ func TestEncodeYUVA(t *testing.T) {
return
}
}
func TestEncodeGray(t *testing.T) {
p := image.NewGray(image.Rect(0, 0, 1, 10))
for i := 0; i < 10; i++ {
p.SetGray(0, i, color.Gray{uint8(float32(i) / 10 * 255)})
}
f := util.CreateFile("TestEncodeGray.webp")
w := bufio.NewWriter(f)
defer func() {
w.Flush()
f.Close()
}()
config, err := webp.ConfigPreset(webp.PresetDefault, 100)
if err != nil {
t.Fatalf("got error: %v", err)
}
if err := webp.EncodeGray(w, p, config); err != nil {
t.Errorf("Got Error: %v", err)
return
}
}