forked from chai2010/webp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cgo.go
196 lines (176 loc) · 4.28 KB
/
cgo.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// Copyright 2016 <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
//#include "webp.h"
import "C"
import "unsafe"
type (
C_int C.int
C_uint C.uint
C_float C.float
C_double C.double
C_size_t C.size_t
C_uint8_t C.uint8_t
C_uint16_t C.uint16_t
C_uint32_t C.uint32_t
C_uint64_t C.uint64_t
C_int8_t C.int8_t
C_int16_t C.int16_t
C_int32_t C.int32_t
C_int64_t C.int64_t
)
func C_webpGetInfo(
data *C_uint8_t, data_size C_size_t,
width *C_int, height *C_int,
has_alpha *C_int,
) C_int {
return C_int(C.webpGetInfo(
(*C.uint8_t)(data), (C.size_t)(data_size),
(*C.int)(width), (*C.int)(height),
(*C.int)(has_alpha),
))
}
func C_webpDecodeGray(
data *C_uint8_t, data_size C_size_t,
width *C_int, height *C_int,
) *C_uint8_t {
return (*C_uint8_t)(C.webpDecodeGray(
(*C.uint8_t)(data), (C.size_t)(data_size),
(*C.int)(width), (*C.int)(height),
))
}
func C_webpDecodeRGB(
data *C_uint8_t, data_size C_size_t,
width *C_int, height *C_int,
) *C_uint8_t {
return (*C_uint8_t)(C.webpDecodeRGB(
(*C.uint8_t)(data), (C.size_t)(data_size),
(*C.int)(width), (*C.int)(height),
))
}
func C_webpDecodeRGBA(
data *C_uint8_t, data_size C_size_t,
width *C_int, height *C_int,
) *C_uint8_t {
return (*C_uint8_t)(C.webpDecodeRGBA(
(*C.uint8_t)(data), (C.size_t)(data_size),
(*C.int)(width), (*C.int)(height),
))
}
func C_webpDecodeGrayToSize(
data *C_uint8_t, data_size C_size_t,
width C_int, height C_int, outStride C_int,
out *C_uint8_t,
) C_int {
return (C_int)(C.webpDecodeGrayToSize(
(*C.uint8_t)(data), (C.size_t)(data_size),
(C.int)(width), (C.int)(height),
(C.int)(outStride),
(*C.uint8_t)(out),
))
}
func C_webpDecodeRGBToSize(
data *C_uint8_t, data_size C_size_t,
width C_int, height C_int, outStride C_int,
out *C_uint8_t,
) C_int {
return (C_int)(C.webpDecodeRGBToSize(
(*C.uint8_t)(data), (C.size_t)(data_size),
(C.int)(width), (C.int)(height),
(C.int)(outStride),
(*C.uint8_t)(out),
))
}
func C_webpDecodeRGBAToSize(
data *C_uint8_t, data_size C_size_t,
width C_int, height C_int, outStride C_int,
out *C_uint8_t,
) C_int {
return (C_int)(C.webpDecodeRGBAToSize(
(*C.uint8_t)(data), (C.size_t)(data_size),
(C.int)(width), (C.int)(height),
(C.int)(outStride),
(*C.uint8_t)(out),
))
}
func C_webpEncodeGray(
pix *C_uint8_t,
width C_int, height C_int, stride C_int,
quality_factor C_float,
output_size *C_size_t,
) *C_uint8_t {
return (*C_uint8_t)(C.webpEncodeGray(
(*C.uint8_t)(pix),
(C.int)(width), (C.int)(height), (C.int)(stride),
(C.float)(quality_factor),
(*C.size_t)(output_size),
))
}
func C_webpEncodeRGB(
pix *C_uint8_t,
width C_int, height C_int, stride C_int,
quality_factor C_float,
output_size *C_size_t,
) *C_uint8_t {
return (*C_uint8_t)(C.webpEncodeRGB(
(*C.uint8_t)(pix),
(C.int)(width), (C.int)(height), (C.int)(stride),
(C.float)(quality_factor),
(*C.size_t)(output_size),
))
}
func C_webpEncodeRGBA(
pix *C_uint8_t,
width C_int, height C_int, stride C_int,
quality_factor C_float,
output_size *C_size_t,
) *C_uint8_t {
return (*C_uint8_t)(C.webpEncodeRGBA(
(*C.uint8_t)(pix),
(C.int)(width), (C.int)(height), (C.int)(stride),
(C.float)(quality_factor),
(*C.size_t)(output_size),
))
}
func C_webpEncodeLosslessGray(
pix *C_uint8_t,
width C_int, height C_int, stride C_int,
output_size *C_size_t,
) *C_uint8_t {
return (*C_uint8_t)(C.webpEncodeLosslessGray(
(*C.uint8_t)(pix),
(C.int)(width), (C.int)(height), (C.int)(stride),
(*C.size_t)(output_size),
))
}
func C_webpEncodeLosslessRGB(
pix *C_uint8_t,
width C_int, height C_int, stride C_int,
output_size *C_size_t,
) *C_uint8_t {
return (*C_uint8_t)(C.webpEncodeLosslessRGB(
(*C.uint8_t)(pix),
(C.int)(width), (C.int)(height), (C.int)(stride),
(*C.size_t)(output_size),
))
}
func C_webpEncodeLosslessRGBA(
exact C_int,
pix *C_uint8_t,
width C_int, height C_int, stride C_int,
output_size *C_size_t,
) *C_uint8_t {
return (*C_uint8_t)(C.webpEncodeLosslessRGBA(
(C.int) (exact),
(*C.uint8_t)(pix),
(C.int)(width), (C.int)(height), (C.int)(stride),
(*C.size_t)(output_size),
))
}
func C_webpMalloc(size C_size_t) unsafe.Pointer {
return C.webpMalloc(C.size_t(size))
}
func C_webpFree(p unsafe.Pointer) {
C.webpFree(p)
}