-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecoder.go
More file actions
136 lines (111 loc) · 4.26 KB
/
decoder.go
File metadata and controls
136 lines (111 loc) · 4.26 KB
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
// Code generated by idiomgen. DO NOT EDIT.
package image
import (
"unsafe"
capi "github.com/AndroidGoLab/ndk/capi/imagedecoder"
)
// Decoder wraps the NDK AImageDecoder handle.
type Decoder struct {
ptr *capi.AImageDecoder
}
// cptr returns the underlying C pointer, or nil if h is nil.
// This allows passing optional (nullable) handle parameters to capi functions.
func (h *Decoder) cptr() *capi.AImageDecoder {
if h == nil {
return nil
}
return h.ptr
}
// Close releases the underlying NDK handle.
func (h *Decoder) Close() error {
if h.ptr == nil {
return nil
}
capi.AImageDecoder_delete(h.ptr)
h.ptr = nil
return nil
}
// NewDecoderFromPointer wraps a raw AImageDecoder pointer.
func NewDecoderFromPointer(ptr unsafe.Pointer) *Decoder {
return &Decoder{ptr: (*capi.AImageDecoder)(ptr)}
}
// Pointer returns the underlying pointer as unsafe.Pointer.
func (h *Decoder) Pointer() unsafe.Pointer {
return unsafe.Pointer(h.ptr)
}
// UintPtr returns the underlying pointer as a uintptr.
// This is useful for interop with gomobile bind, golang.org/x/mobile,
// gioui.org, and other packages that represent native handles as uintptr.
func (h *Decoder) UintPtr() uintptr {
return uintptr(unsafe.Pointer(h.ptr))
}
// NewDecoderFromUintPtr wraps a uintptr as a Decoder.
// The caller must ensure ptr points to a valid AImageDecoder.
func NewDecoderFromUintPtr(ptr uintptr) *Decoder {
return &Decoder{ptr: (*capi.AImageDecoder)(unsafe.Pointer(ptr))}
}
// AdvanceFrame calls the underlying NDK function.
func (h *Decoder) AdvanceFrame() error {
return result(capi.AImageDecoder_advanceFrame(h.ptr))
}
// ComputeSampledSize calls the underlying NDK function.
func (h *Decoder) ComputeSampledSize(sampleSize int32, width *int32, height *int32) error {
return result(capi.AImageDecoder_computeSampledSize(h.ptr, sampleSize, width, height))
}
// Decode calls the underlying NDK function.
func (h *Decoder) Decode(pixels unsafe.Pointer, stride uint64, size uint64) error {
return result(capi.AImageDecoder_decodeImage(h.ptr, pixels, stride, size))
}
// GetFrameInfo calls the underlying NDK function.
func (h *Decoder) GetFrameInfo(info *ImageDecoderFrameInfo) error {
return result(capi.AImageDecoder_getFrameInfo(h.ptr, info.cptr()))
}
// HeaderInfo creates a new HeaderInfo from this Decoder.
func (h *Decoder) HeaderInfo() *HeaderInfo {
return &HeaderInfo{ptr: capi.AImageDecoder_getHeaderInfo(h.ptr)}
}
// MinimumStride returns the value directly.
func (h *Decoder) MinimumStride() uint64 {
return (uint64)(capi.AImageDecoder_getMinimumStride(h.ptr))
}
// GetRepeatCount calls the underlying NDK function.
func (h *Decoder) GetRepeatCount() error {
return result(capi.AImageDecoder_getRepeatCount(h.ptr))
}
// IsAnimated returns the value directly.
func (h *Decoder) IsAnimated() bool {
return (bool)(capi.AImageDecoder_isAnimated(h.ptr))
}
// Rewind calls the underlying NDK function.
func (h *Decoder) Rewind() error {
return result(capi.AImageDecoder_rewind(h.ptr))
}
// SetAndroidBitmapFormat calls the underlying NDK function.
func (h *Decoder) SetAndroidBitmapFormat(format int32) error {
return result(capi.AImageDecoder_setAndroidBitmapFormat(h.ptr, format))
}
// SetDataSpace calls the underlying NDK function.
func (h *Decoder) SetDataSpace(dataspace int32) error {
return result(capi.AImageDecoder_setDataSpace(h.ptr, dataspace))
}
// SetInternallyHandleDisposePrevious calls the underlying NDK function.
func (h *Decoder) SetInternallyHandleDisposePrevious(handleInternally bool) {
capi.AImageDecoder_setInternallyHandleDisposePrevious(h.ptr, handleInternally)
}
// SetTargetSize calls the underlying NDK function.
func (h *Decoder) SetTargetSize(width int32, height int32) error {
return result(capi.AImageDecoder_setTargetSize(h.ptr, width, height))
}
// SetUnpremultipliedRequired calls the underlying NDK function.
func (h *Decoder) SetUnpremultipliedRequired(unpremultipliedRequired bool) error {
return result(capi.AImageDecoder_setUnpremultipliedRequired(h.ptr, unpremultipliedRequired))
}
// NewDecoderFromFd calls the underlying C function.
func NewDecoderFromFd(fd int32) (*Decoder, error) {
var outDecoderPtr *capi.AImageDecoder
ret := capi.AImageDecoder_createFromFd(fd, &outDecoderPtr)
if err := result(ret); err != nil {
return nil, err
}
return &Decoder{ptr: outDecoderPtr}, nil
}