mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-02 23:23:55 +00:00
add bitmap string func
This commit is contained in:
parent
5afcb0af9c
commit
b8e7e584a7
@ -108,6 +108,19 @@ MMBitmapRef bitmap_open(char *path, uint16_t ttype){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMBitmapRef bitmap_from_string(const char *str){
|
||||||
|
size_t len = strlen(str);
|
||||||
|
|
||||||
|
MMBitmapRef bitmap;
|
||||||
|
MMBMPStringError err;
|
||||||
|
|
||||||
|
if ((bitmap = createMMBitmapFromString((unsigned char*)str, len, &err)) == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
char *bitmap_save(MMBitmapRef bitmap, char *path, uint16_t type){
|
char *bitmap_save(MMBitmapRef bitmap, char *path, uint16_t type){
|
||||||
if (saveMMBitmapToFile(bitmap, path, (MMImageType) type) != 0) {
|
if (saveMMBitmapToFile(bitmap, path, (MMImageType) type) != 0) {
|
||||||
return "Could not save image to file.";
|
return "Could not save image to file.";
|
||||||
|
10
robotgo.go
10
robotgo.go
@ -55,7 +55,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
version string = "v0.46.0.400, Pyrenees Mountains!"
|
version string = "v0.46.0.401, Pyrenees Mountains!"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetVersion get version
|
// GetVersion get version
|
||||||
@ -638,6 +638,14 @@ func OpenBitmap(args ...interface{}) C.MMBitmapRef {
|
|||||||
// defer C.free(unsafe.Pointer(path))
|
// defer C.free(unsafe.Pointer(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BitmapStr bitmap from string
|
||||||
|
func BitmapStr(str string) C.MMBitmapRef {
|
||||||
|
cs := C.CString(str)
|
||||||
|
bit := C.bitmap_from_string(cs)
|
||||||
|
defer C.free(unsafe.Pointer(cs))
|
||||||
|
return bit
|
||||||
|
}
|
||||||
|
|
||||||
// SaveBitmap save the bitmap
|
// SaveBitmap save the bitmap
|
||||||
func SaveBitmap(args ...interface{}) string {
|
func SaveBitmap(args ...interface{}) string {
|
||||||
var mtype C.uint16_t
|
var mtype C.uint16_t
|
||||||
|
Loading…
Reference in New Issue
Block a user