fix OpenBitmap & add Convert

This commit is contained in:
vCaesar 2016-10-30 19:16:03 +08:00
parent 799ebac040
commit f1e8b762f1
2 changed files with 29 additions and 6 deletions

View File

@ -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;

View File

@ -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)
}
/*
------------ --- --- ------------ ---- ---- ------------
************ *** *** ************ ***** **** ************