mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 06:33:56 +00:00
add get pixel color return hex
This commit is contained in:
parent
fe2dc55988
commit
b55f438c1b
14
robotgo.go
14
robotgo.go
@ -62,7 +62,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
version string = "v0.47.0.445, Mount Cook!"
|
||||
version string = "v0.47.0.447, Mount Cook!"
|
||||
)
|
||||
|
||||
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 {
|
||||
cx := C.size_t(x)
|
||||
cy := C.size_t(y)
|
||||
|
||||
color := C.aGetPixelColor(cx, cy)
|
||||
// color := C.aGetPixelColor(x, y)
|
||||
gcolor := C.GoString(color)
|
||||
|
@ -19,6 +19,21 @@ void padHex(MMRGBHex color, char* hex){
|
||||
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){
|
||||
MMBitmapRef bitmap;
|
||||
|
Loading…
Reference in New Issue
Block a user