@@ -38,6 +38,7 @@ extern uint8_t _InputText(MaaStringView text, MaaTransparentArg handle_arg);
38
38
*/
39
39
import "C"
40
40
import (
41
+ "image"
41
42
"unsafe"
42
43
)
43
44
@@ -52,7 +53,7 @@ type CustomControllerImpl interface {
52
53
RequestUUID () (string , bool )
53
54
StartApp (intent string ) bool
54
55
StopApp (intent string ) bool
55
- Screencap () (ImageBuffer , bool )
56
+ Screencap () (image. Image , bool )
56
57
Click (x , y int32 ) bool
57
58
Swipe (x1 , y1 , x2 , y2 , duration int32 ) bool
58
59
TouchDown (contact , x , y , pressure int32 ) bool
@@ -140,10 +141,12 @@ func _StopAppAgent(intent string, handleArg C.MaaTransparentArg) C.uint8_t {
140
141
func _ScreencapAgent (handleArg C.MaaTransparentArg , buffer C.MaaImageBufferHandle ) C.uint8_t {
141
142
ctrl := * (* CustomControllerImpl )(unsafe .Pointer (handleArg ))
142
143
img , ok := ctrl .Screencap ()
143
- defer img .Destroy ()
144
144
if ok {
145
145
imgBuffer := & imageBuffer {handle : buffer }
146
- imgBuffer .SetRawData (img .GetRawData (), img .GetWidth (), img .GetHeight (), img .GetType ())
146
+ err := imgBuffer .SetRawData (img )
147
+ if err != nil {
148
+ return C .uint8_t (0 )
149
+ }
147
150
return C .uint8_t (1 )
148
151
}
149
152
return C .uint8_t (0 )
0 commit comments