mirror of
https://github.com/talgo-cloud/talgo-libwebp.git
synced 2026-03-15 02:05:59 -07:00
Impl EncodeGray.
This commit is contained in:
parent
00f04ef2a9
commit
3a78b3d0d3
2 changed files with 86 additions and 0 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue