mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-02 23:23:55 +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
|
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
|
||||||
.glide/
|
.glide/
|
||||||
|
examples/bitmap/teststr.png
|
||||||
|
@ -157,8 +157,8 @@ MMBitmapRef bitmap_from_string(const char *str){
|
|||||||
MMBMPStringError err;
|
MMBMPStringError err;
|
||||||
|
|
||||||
if ((bitmap = createMMBitmapFromString(
|
if ((bitmap = createMMBitmapFromString(
|
||||||
(unsigned char*)str, len, &err))
|
(unsigned char*)str, len, &err )
|
||||||
== NULL) {
|
) == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +83,9 @@ func bitmap() {
|
|||||||
|
|
||||||
// sbitmap := robotgo.BitmapFromstring(bitstr, 2)
|
// sbitmap := robotgo.BitmapFromstring(bitstr, 2)
|
||||||
// fmt.Println("...", sbitmap)
|
// 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
|
// saves image to absolute filepath in the given format
|
||||||
robotgo.SaveBitmap(bitmap, "test.png")
|
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)
|
fx, fy := internalFindBitmap(bit, sbit, tolerance)
|
||||||
FreeBitmap(bit)
|
// FreeBitmap(bit)
|
||||||
FreeBitmap(sbit)
|
if len(args) <= 0 {
|
||||||
|
FreeBitmap(sbit)
|
||||||
|
}
|
||||||
|
|
||||||
return fx, fy
|
return fx, fy
|
||||||
}
|
}
|
||||||
@ -851,7 +853,9 @@ func FindPic(path string, args ...interface{}) (int, int) {
|
|||||||
|
|
||||||
fx, fy := internalFindBitmap(openbit, sbit, tolerance)
|
fx, fy := internalFindBitmap(openbit, sbit, tolerance)
|
||||||
FreeBitmap(openbit)
|
FreeBitmap(openbit)
|
||||||
FreeBitmap(sbit)
|
if len(args) <= 0 {
|
||||||
|
FreeBitmap(sbit)
|
||||||
|
}
|
||||||
|
|
||||||
return fx, fy
|
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)
|
pos := C.find_every_bitmap(bit, sbit, tolerance, &lpos)
|
||||||
FreeBitmap(bit)
|
// FreeBitmap(bit)
|
||||||
FreeBitmap(sbit)
|
if len(args) <= 0 {
|
||||||
|
FreeBitmap(sbit)
|
||||||
|
}
|
||||||
|
|
||||||
// fmt.Println("pos----", pos)
|
// fmt.Println("pos----", pos)
|
||||||
return int(pos.x), int(pos.y)
|
return int(pos.x), int(pos.y)
|
||||||
|
Loading…
Reference in New Issue
Block a user