Add more bitmap func

This commit is contained in:
vCaesar 2017-06-06 22:56:48 +08:00
parent 72d330fecf
commit a98f122d4c
2 changed files with 40 additions and 0 deletions

View File

@ -28,6 +28,32 @@
#include <assert.h>
#include <stdio.h>
/* Returns false and sets error if |bitmap| is NULL. */
bool bitmap_ready(MMBitmapRef bitmap){
if (bitmap == NULL || bitmap->imageBuffer == NULL) {
return false;
}
return true;
}
void bitmap_dealloc(MMBitmapRef bitmap){
if (bitmap != NULL) {
destroyMMBitmap(bitmap);
bitmap = NULL;
}
}
bool bitmap_copy_to_pboard(MMBitmapRef bitmap){
MMPasteError err;
if (!bitmap_ready(bitmap)) return false;
if ((err = copyMMBitmapToPasteboard(bitmap)) != kMMPasteNoError) {
return false;
}
return true;
}
MMPoint aFindBitmap(MMBitmapRef bit_map, MMRect rect){
// MMRect rect;
// rect.size.width = 10;

View File

@ -644,6 +644,20 @@ func FreeBitmap(ref C.MMBitmapRef) {
C.destroyMMBitmap(ref)
}
// ReadBitmap returns false and sets error if |bitmap| is NULL
func ReadBitmap(bitmap C.MMBitmapRef) bool {
abool := C.bitmap_ready(bitmap)
gbool := bool(abool)
return gbool
}
// CopyBitpb copy bitmap to pasteboard
func CopyBitpb(bitmap C.MMBitmapRef) bool {
abool := C.bitmap_copy_to_pboard(bitmap)
gbool := bool(abool)
return gbool
}
/*
___________ ____ _______ .__ __. .___________.
| ____\ \ / / | ____|| \ | | | |