mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 06:33:56 +00:00
fix OpenBitmap & add Convert
This commit is contained in:
parent
799ebac040
commit
f1e8b762f1
@ -37,13 +37,13 @@ MMPoint aFindBitmap(MMBitmapRef bit_map,MMRect rect){
|
||||
return point;
|
||||
}
|
||||
|
||||
MMBitmapRef aOpenBitmap(char *path){
|
||||
MMImageType type;
|
||||
MMBitmapRef aOpenBitmap(char *path ,uint16_t ttype){
|
||||
// MMImageType type;
|
||||
|
||||
MMBitmapRef bitmap;
|
||||
MMIOError err;
|
||||
|
||||
bitmap = newMMBitmapFromFile(path, type, &err);
|
||||
bitmap = newMMBitmapFromFile(path, ttype, &err);
|
||||
// printf("....%zd\n",bitmap->width);
|
||||
return bitmap;
|
||||
|
||||
|
29
robotgo.go
29
robotgo.go
@ -289,9 +289,16 @@ func FindBitmap(args ...interface{}) (C.size_t, C.size_t) {
|
||||
return pos.x, pos.y
|
||||
}
|
||||
|
||||
func OpenBitmap(gpath string) C.MMBitmapRef {
|
||||
path := C.CString(gpath)
|
||||
bit := C.aOpenBitmap(path)
|
||||
func OpenBitmap(args ...interface{}) C.MMBitmapRef {
|
||||
path := C.CString(args[0].(string))
|
||||
var mtype C.uint16_t
|
||||
Try(func() {
|
||||
mtype = C.uint16_t(args[1].(int))
|
||||
}, func(e interface{}) {
|
||||
// Println("err:::", e)
|
||||
mtype = 1
|
||||
})
|
||||
bit := C.aOpenBitmap(path, mtype)
|
||||
// Println("opening...", bit)
|
||||
return bit
|
||||
// defer C.free(unsafe.Pointer(path))
|
||||
@ -338,6 +345,22 @@ func GetPortion(bit C.MMBitmapRef, x, y, w, h C.size_t) C.MMBitmapRef {
|
||||
return pos
|
||||
}
|
||||
|
||||
func Convert(args ...interface{}) {
|
||||
var mtype int
|
||||
Try(func() {
|
||||
mtype = args[2].(int)
|
||||
}, func(e interface{}) {
|
||||
Println("err:::", e)
|
||||
mtype = 1
|
||||
})
|
||||
//C.CString()
|
||||
opath := args[0].(string)
|
||||
spath := args[1].(string)
|
||||
bit_map := OpenBitmap(opath)
|
||||
// Println("a----", bit_map)
|
||||
SaveBitmap(bit_map, spath, mtype)
|
||||
}
|
||||
|
||||
/*
|
||||
------------ --- --- ------------ ---- ---- ------------
|
||||
************ *** *** ************ ***** **** ************
|
||||
|
Loading…
Reference in New Issue
Block a user