mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 06:33:56 +00:00
just free internal bitmap and add bitmapStr example
This commit is contained in:
parent
5ab8d85856
commit
111d1badb1
1
.gitignore
vendored
1
.gitignore
vendored
@ -67,3 +67,4 @@ _testmain.go
|
||||
|
||||
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
|
||||
.glide/
|
||||
examples/bitmap/teststr.png
|
||||
|
@ -157,8 +157,8 @@ MMBitmapRef bitmap_from_string(const char *str){
|
||||
MMBMPStringError err;
|
||||
|
||||
if ((bitmap = createMMBitmapFromString(
|
||||
(unsigned char*)str, len, &err))
|
||||
== NULL) {
|
||||
(unsigned char*)str, len, &err )
|
||||
) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,9 @@ func bitmap() {
|
||||
|
||||
// sbitmap := robotgo.BitmapFromstring(bitstr, 2)
|
||||
// fmt.Println("...", sbitmap)
|
||||
sbitmap := robotgo.BitmapStr(bitstr)
|
||||
fmt.Println("bitmap str...", sbitmap)
|
||||
robotgo.SaveBitmap(sbitmap, "teststr.png")
|
||||
|
||||
// saves image to absolute filepath in the given format
|
||||
robotgo.SaveBitmap(bitmap, "test.png")
|
||||
|
16
robotgo.go
16
robotgo.go
@ -819,8 +819,10 @@ func FindBitmap(bit C.MMBitmapRef, args ...interface{}) (int, int) {
|
||||
}
|
||||
|
||||
fx, fy := internalFindBitmap(bit, sbit, tolerance)
|
||||
FreeBitmap(bit)
|
||||
FreeBitmap(sbit)
|
||||
// FreeBitmap(bit)
|
||||
if len(args) <= 0 {
|
||||
FreeBitmap(sbit)
|
||||
}
|
||||
|
||||
return fx, fy
|
||||
}
|
||||
@ -851,7 +853,9 @@ func FindPic(path string, args ...interface{}) (int, int) {
|
||||
|
||||
fx, fy := internalFindBitmap(openbit, sbit, tolerance)
|
||||
FreeBitmap(openbit)
|
||||
FreeBitmap(sbit)
|
||||
if len(args) <= 0 {
|
||||
FreeBitmap(sbit)
|
||||
}
|
||||
|
||||
return fx, fy
|
||||
}
|
||||
@ -890,8 +894,10 @@ func FindEveryBitmap(bit C.MMBitmapRef, args ...interface{}) (int, int) {
|
||||
}
|
||||
|
||||
pos := C.find_every_bitmap(bit, sbit, tolerance, &lpos)
|
||||
FreeBitmap(bit)
|
||||
FreeBitmap(sbit)
|
||||
// FreeBitmap(bit)
|
||||
if len(args) <= 0 {
|
||||
FreeBitmap(sbit)
|
||||
}
|
||||
|
||||
// fmt.Println("pos----", pos)
|
||||
return int(pos.x), int(pos.y)
|
||||
|
Loading…
Reference in New Issue
Block a user