mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 06:33:56 +00:00
Add getcolor and Update examples
This commit is contained in:
parent
979a569eda
commit
6d2317ee69
@ -145,3 +145,16 @@ MMBitmapRef get_Portion(MMBitmapRef bit_map, MMRect rect){
|
||||
portion = copyMMBitmapFromPortion(bit_map, rect);
|
||||
return portion;
|
||||
}
|
||||
|
||||
MMRGBHex bitmap_get_color(MMBitmapRef bitmap, size_t x, size_t y){
|
||||
if (!bitmap_ready(bitmap)) return 0;
|
||||
|
||||
MMPoint point;
|
||||
point = MMPointMake(x, y);
|
||||
|
||||
if (!MMBitmapPointInBounds(bitmap, point)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return MMRGBHexAtPoint(bitmap, point.x, point.y);
|
||||
}
|
||||
|
@ -30,6 +30,9 @@ func main() {
|
||||
bitmap := robotgo.CaptureScreen(100, 200, 30, 40)
|
||||
fmt.Println("CaptureScreen...", bitmap)
|
||||
|
||||
color := robotgo.GetColor(bitmap, 1, 2)
|
||||
fmt.Println("color...", color)
|
||||
|
||||
// searches for needle in bitmap
|
||||
fx, fy := robotgo.FindBit(bitmap)
|
||||
fmt.Println("FindBitmap------", fx, fy)
|
||||
|
@ -140,6 +140,9 @@ func bitmap() {
|
||||
bitmap := robotgo.CaptureScreen(100, 200, 30, 40)
|
||||
fmt.Println("CaptureScreen...", bitmap)
|
||||
|
||||
color := robotgo.GetColor(bitmap, 1, 2)
|
||||
fmt.Println("color...", color)
|
||||
|
||||
// searches for needle in bitmap
|
||||
fx, fy := robotgo.FindBit(bitmap)
|
||||
fmt.Println("FindBitmap------", fx, fy)
|
||||
|
@ -729,6 +729,13 @@ func DeepCopyBit(bitmap C.MMBitmapRef) C.MMBitmapRef {
|
||||
return bit
|
||||
}
|
||||
|
||||
// GetColor get bitmap color
|
||||
func GetColor(bitmap C.MMBitmapRef, x, y int) C.MMRGBHex {
|
||||
color := C.bitmap_get_color(bitmap, C.size_t(x), C.size_t(y))
|
||||
|
||||
return color
|
||||
}
|
||||
|
||||
/*
|
||||
___________ ____ _______ .__ __. .___________.
|
||||
| ____\ \ / / | ____|| \ | | | |
|
||||
|
Loading…
Reference in New Issue
Block a user