-
Notifications
You must be signed in to change notification settings - Fork 90
/
writer_example_test.go
69 lines (57 loc) · 1.31 KB
/
writer_example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2015 <chaishushan{AT}gmail.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package webp
import (
"bytes"
"image"
"log"
"os"
"reflect"
)
func ExampleSave() {
tmpname := "z_test_ExampleSave.webp"
defer os.Remove(tmpname)
gray := NewMemPImage(image.Rect(0, 0, 400, 300), 1, reflect.Uint8)
if err := Save(tmpname, gray, &Options{Quality: 75}); err != nil {
log.Fatal(err)
}
}
func ExampleEncode() {
m, err := Load("./testdata/1_webp_ll.webp")
if err != nil {
log.Fatal(err)
}
var buf bytes.Buffer
if err := Encode(&buf, m, nil); err != nil {
log.Fatal(err)
}
_ = buf.Bytes()
}
func ExampleEncode_lossless() {
m, err := Load("./testdata/1_webp_ll.webp")
if err != nil {
log.Fatal(err)
}
var buf bytes.Buffer
if err := Encode(&buf, m, &Options{Lossless: true}); err != nil {
log.Fatal(err)
}
_ = buf.Bytes()
}
func ExampleEncode_rgb() {
rgb := NewRGBImage(image.Rect(0, 0, 400, 300))
var buf bytes.Buffer
if err := Encode(&buf, rgb, nil); err != nil {
log.Fatal(err)
}
_ = buf.Bytes()
}
func ExampleEncode_rgb48MemP() {
rgb48 := NewMemPImage(image.Rect(0, 0, 400, 300), 3, reflect.Uint16)
var buf bytes.Buffer
if err := Encode(&buf, rgb48, nil); err != nil {
log.Fatal(err)
}
_ = buf.Bytes()
}