add bitmap string func

This commit is contained in:
vcaesar 2017-10-28 21:41:20 +08:00
parent 5afcb0af9c
commit b8e7e584a7
2 changed files with 22 additions and 1 deletions

View File

@ -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){
if (saveMMBitmapToFile(bitmap, path, (MMImageType) type) != 0) {
return "Could not save image to file.";

View File

@ -55,7 +55,7 @@ import (
)
const (
version string = "v0.46.0.400, Pyrenees Mountains!"
version string = "v0.46.0.401, Pyrenees Mountains!"
)
// GetVersion get version
@ -638,6 +638,14 @@ func OpenBitmap(args ...interface{}) C.MMBitmapRef {
// 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
func SaveBitmap(args ...interface{}) string {
var mtype C.uint16_t