Skip to content

Commit

Permalink
refactor: Get function of ImageListBuffer return image.Image and error
Browse files Browse the repository at this point in the history
  • Loading branch information
dongwlin committed Aug 12, 2024
1 parent a44bab1 commit 0ae9580
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions buffer_image_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ package maa
#include <MaaFramework/MaaAPI.h>
*/
import "C"
import "unsafe"
import (
"image"
"unsafe"
)

type ImageListBuffer interface {
Destroy()
Handle() unsafe.Pointer
IsEmpty() bool
Clear() bool
Size() uint64
Get(index uint64) ImageBuffer
Get(index uint64) (image.Image, error)
Append(value ImageBuffer) bool
Remove(index uint64) bool
}
Expand Down Expand Up @@ -47,9 +50,10 @@ func (il *imageListBuffer) Size() uint64 {
return uint64(C.MaaGetImageListSize(il.handle))
}

func (il *imageListBuffer) Get(index uint64) ImageBuffer {
func (il *imageListBuffer) Get(index uint64) (image.Image, error) {
handle := C.MaaGetImageListAt(il.handle, C.uint64_t(index))
return &imageBuffer{handle: handle}
img := &imageBuffer{handle: handle}
return img.GetByRawData()
}

func (il *imageListBuffer) Append(value ImageBuffer) bool {
Expand Down

0 comments on commit 0ae9580

Please sign in to comment.