-
Notifications
You must be signed in to change notification settings - Fork 1
/
histogram.go
45 lines (36 loc) · 1.35 KB
/
histogram.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
/*
Copyright (c) 2016, The go-imagequant author(s)
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD TO
THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
*/
package imagequant
/*
#include "libimagequant.h"
*/
import "C"
type Histogram struct {
p *C.struct_liq_histogram
}
func (this *Histogram) AddImage(attr *Attributes, img *Image) error {
return translateError(C.liq_histogram_add_image(this.p, attr.p, img.p))
}
func (this *Histogram) Quantize(attr *Attributes) (*Result, error) {
res := Result{}
liqerr := C.liq_histogram_quantize(this.p, attr.p, &res.p)
if liqerr != C.LIQ_OK {
return nil, translateError(liqerr)
}
return &res, nil
}
// Free memory. Callers must not use this object after Release has been called.
func (this *Histogram) Release() {
C.liq_histogram_destroy(this.p)
}