add get pixel color return hex

This commit is contained in:
vcaesar 2017-12-23 23:38:35 +08:00
parent fe2dc55988
commit b55f438c1b
2 changed files with 27 additions and 2 deletions

View File

@ -62,7 +62,7 @@ import (
) )
const ( const (
version string = "v0.47.0.445, Mount Cook!" version string = "v0.47.0.447, Mount Cook!"
) )
type ( type (
@ -112,10 +112,20 @@ func Try(fun func(), handler func(interface{})) {
|_______/ \______|| _| `._____||_______||_______||__| \__| |_______/ \______|| _| `._____||_______||_______||__| \__|
*/ */
// GetPixelColor get pixel color // GetPxColor get pixel color return C.MMRGBHex
func GetPxColor(x, y int) C.MMRGBHex {
cx := C.size_t(x)
cy := C.size_t(y)
color := C.get_Pixel_Color(cx, cy)
return color
}
// GetPixelColor get pixel color return string
func GetPixelColor(x, y int) string { func GetPixelColor(x, y int) string {
cx := C.size_t(x) cx := C.size_t(x)
cy := C.size_t(y) cy := C.size_t(y)
color := C.aGetPixelColor(cx, cy) color := C.aGetPixelColor(cx, cy)
// color := C.aGetPixelColor(x, y) // color := C.aGetPixelColor(x, y)
gcolor := C.GoString(color) gcolor := C.GoString(color)

View File

@ -19,6 +19,21 @@ void padHex(MMRGBHex color, char* hex){
snprintf(hex, 7, "%06x", color); snprintf(hex, 7, "%06x", color);
} }
MMRGBHex get_Pixel_Color(size_t x, size_t y){
MMBitmapRef bitmap;
MMRGBHex color;
if (!pointVisibleOnMainDisplay(MMPointMake(x, y))){
return color;
}
bitmap = copyMMBitmapFromDisplayInRect(MMRectMake(x, y, 1, 1));
// bitmap = MMRectMake(x, y, 1, 1);
color = MMRGBHexAtPoint(bitmap, 0, 0);
return color;
}
char* aGetPixelColor(size_t x, size_t y){ char* aGetPixelColor(size_t x, size_t y){
MMBitmapRef bitmap; MMBitmapRef bitmap;