diff --git a/bitmap/goBitmap.h b/bitmap/goBitmap.h index 9cfa9c1..2a96da5 100644 --- a/bitmap/goBitmap.h +++ b/bitmap/goBitmap.h @@ -30,11 +30,11 @@ MMBitmapRef aOpenBitmap(char *path){ } -char *aSaveBitmap(MMBitmapRef bitmap,char *path, MMImageType type){ - if (saveMMBitmapToFile(bitmap, path, type) != 0) { +char *aSaveBitmap(MMBitmapRef bitmap,char *path, uint16_t type){ + if (saveMMBitmapToFile(bitmap, path,(MMImageType) type) != 0) { return "Could not save image to file."; }else{ - saveMMBitmapToFile(bitmap, path, type); + saveMMBitmapToFile(bitmap, path, (MMImageType) type); } //destroyMMBitmap(bitmap); return "ok"; diff --git a/robotgo.go b/robotgo.go index dc285e0..cc4f939 100644 --- a/robotgo.go +++ b/robotgo.go @@ -231,30 +231,30 @@ func OpenBitmap(gpath string) C.MMBitmapRef { // defer C.free(unsafe.Pointer(path)) } -// func SaveBitmap(args ...interface{}) { -// var mtype C.MMImageType -// Try(func() { -// mtype = args[2].(C.MMImageType) -// }, func(e interface{}) { -// Println("err:::", e) -// mtype = 1 -// }) +func SaveBitmap(args ...interface{}) { + var mtype C.uint16_t + Try(func() { + mtype = C.uint16_t(args[2].(int)) + }, func(e interface{}) { + Println("err:::", e) + mtype = 1 + }) -// path := C.CString(args[1].(string)) -// savebit := C.aSaveBitmap(args[0].(C.MMBitmapRef), path, mtype) -// Println("opening...", savebit) -// // return bit -// // defer C.free(unsafe.Pointer(path)) -// } - -func SaveBitmap(bit C.MMBitmapRef, gpath string, mtype C.MMImageType) { - path := C.CString(gpath) - savebit := C.aSaveBitmap(bit, path, mtype) + path := C.CString(args[1].(string)) + savebit := C.aSaveBitmap(args[0].(C.MMBitmapRef), path, mtype) Println("opening...", savebit) // return bit // defer C.free(unsafe.Pointer(path)) } +// func SaveBitmap(bit C.MMBitmapRef, gpath string, mtype C.MMImageType) { +// path := C.CString(gpath) +// savebit := C.aSaveBitmap(bit, path, mtype) +// Println("opening...", savebit) +// // return bit +// // defer C.free(unsafe.Pointer(path)) +// } + func TostringBitmap(bit C.MMBitmapRef) *C.char { str_bit := C.aTostringBitmap(bit) // Println("...", str_bit)