From f147f7866a64eb59176359ca874e81dd1b1b90c4 Mon Sep 17 00:00:00 2001 From: vCaesar Date: Thu, 20 Oct 2016 17:32:45 +0800 Subject: [PATCH] Update bitmap test --- robotgo.go | 28 ++++++++++++++++++---------- test/main.go | 2 ++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/robotgo.go b/robotgo.go index 57c3d28..3840d57 100644 --- a/robotgo.go +++ b/robotgo.go @@ -225,17 +225,25 @@ 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.MMImageType +// Try(func() { +// mtype = args[2].(C.MMImageType) +// }, func(e interface{}) { +// Println("err:::", e) +// mtype = 1 +// }) - path := C.CString(args[1].(string)) - savebit := C.aSaveBitmap(args[0].(C.MMBitmapRef), 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)) diff --git a/test/main.go b/test/main.go index 7328b54..7357350 100644 --- a/test/main.go +++ b/test/main.go @@ -28,6 +28,8 @@ func arobotgo() { bit_map := robotgo.CaptureScreen(10, 20, 30, 40) Println("...", bit_map) + robotgo.SaveBitmap(bit_map, "test.png", 1) + // robotgo.MouseClick() robotgo.ScrollMouse(10, "up") }