-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathturbojpeg.go
111 lines (100 loc) · 2.43 KB
/
turbojpeg.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
package turbojpeg
/*
#cgo CFLAGS: -I${SRCDIR}/include -I/usr/local/include -I/usr/include -I/opt/libjpeg-turbo/include
#cgo LDFLAGS: -L${SRCDIR} -L/usr/local/lib -L/usr/lib -L/opt/libjpeg-turbo/lib64 -L/opt/libjpeg-turbo/lib -lturbojpeg -lm -ldl
#include "turbojpeg.h"
*/
import "C"
type Subsampling C.int
const (
Subsampling444 Subsampling = C.TJSAMP_444
Subsampling422 Subsampling = C.TJSAMP_422
Subsampling420 Subsampling = C.TJSAMP_420
SubsamplingGray Subsampling = C.TJSAMP_GRAY
Subsampling440 Subsampling = C.TJSAMP_440
Subsampling411 Subsampling = C.TJSAMP_411
)
func (s Subsampling) String() string {
switch s {
case Subsampling444:
return "4:4:4"
case Subsampling422:
return "4:2:2"
case Subsampling420:
return "4:2:0"
case SubsamplingGray:
return "gray"
case Subsampling440:
return "4:4:0"
case Subsampling411:
return "4:1:1"
}
return "unknown"
}
type PixelFormat C.int
const (
PixelFormatRGB PixelFormat = C.TJPF_RGB
PixelFormatBGR PixelFormat = C.TJPF_BGR
PixelFormatRGBX PixelFormat = C.TJPF_RGBX
PixelFormatBGRX PixelFormat = C.TJPF_BGRX
PixelFormatXBGR PixelFormat = C.TJPF_XBGR
PixelFormatXRGB PixelFormat = C.TJPF_XRGB
PixelFormatGray PixelFormat = C.TJPF_GRAY
PixelFormatRGBA PixelFormat = C.TJPF_RGBA
PixelFormatBGRA PixelFormat = C.TJPF_BGRA
PixelFormatABGR PixelFormat = C.TJPF_ABGR
PixelFormatARGB PixelFormat = C.TJPF_ARGB
PixelFormatCMYK PixelFormat = C.TJPF_CMYK
)
func (p PixelFormat) String() string {
switch p {
case PixelFormatRGB:
return "RGB"
case PixelFormatBGR:
return "BGR"
case PixelFormatRGBX:
return "RGBX"
case PixelFormatBGRX:
return "BGRX"
case PixelFormatXBGR:
return "XBGR"
case PixelFormatXRGB:
return "XRGB"
case PixelFormatGray:
return "gray"
case PixelFormatRGBA:
return "RGBA"
case PixelFormatBGRA:
return "BGRA"
case PixelFormatABGR:
return "ABGR"
case PixelFormatARGB:
return "ARGB"
case PixelFormatCMYK:
return "CMYK"
}
return "unknown"
}
type ColorSpace C.int
const (
ColorSpaceRGB ColorSpace = C.TJCS_RGB
ColorSpaceYCbCr ColorSpace = C.TJCS_YCbCr
ColorSpaceGray ColorSpace = C.TJCS_GRAY
ColorSpaceCMYK ColorSpace = C.TJCS_CMYK
ColorSpaceYCCK ColorSpace = C.TJCS_YCCK
)
func (c ColorSpace) String() string {
switch c {
case ColorSpaceRGB:
return "RGB"
case ColorSpaceYCbCr:
return "YCbCr"
case ColorSpaceGray:
return "gray"
case ColorSpaceCMYK:
return "CMYK"
case ColorSpaceYCCK:
return "YCCK"
}
return "unknown"
}