-
Notifications
You must be signed in to change notification settings - Fork 3
/
gdiplusimagecodec.go
53 lines (44 loc) · 1.56 KB
/
gdiplusimagecodec.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
package gdiplus
import (
"unsafe"
. "github.com/tryor/winapi"
)
//--------------------------------------------------------------------------
// Codec Management APIs
//--------------------------------------------------------------------------
func GetImageDecodersSize() (numDecoders UINT, size UINT, status Status) {
status, _ = GdipGetImageDecodersSize(&numDecoders, &size)
return
}
func GetImageDecoders(
numDecoders UINT, size UINT) (decoders []*ImageCodecInfo, status Status) {
decodersbuf := make([]byte, size)
decoder := (*ImageCodecInfo)(unsafe.Pointer(&decodersbuf[0]))
status, _ = GdipGetImageDecoders(numDecoders, size, decoder)
if status == Ok {
decoders = make([]*ImageCodecInfo, numDecoders)
for i := UINT(0); i < numDecoders; i++ {
decoder = (*ImageCodecInfo)(unsafe.Pointer((uintptr(unsafe.Pointer(decoder)) + uintptr(i*ImageCodecInfo_SIZE))))
decoders[i] = decoder
}
}
return
}
func GetImageEncodersSize() (numEncoders UINT, size UINT, status Status) {
status, _ = GdipGetImageEncodersSize(&numEncoders, &size)
return
}
func GetImageEncoders(
numEncoders UINT, size UINT) (decoders []*ImageCodecInfo, status Status) {
decodersbuf := make([]byte, size)
decoder := (*ImageCodecInfo)(unsafe.Pointer(&decodersbuf[0]))
status, _ = GdipGetImageEncoders(numEncoders, size, decoder)
if status == Ok {
decoders = make([]*ImageCodecInfo, numEncoders)
for i := UINT(0); i < numEncoders; i++ {
decoder = (*ImageCodecInfo)(unsafe.Pointer((uintptr(unsafe.Pointer(decoder)) + uintptr(i*ImageCodecInfo_SIZE))))
decoders[i] = decoder
}
}
return
}