Add getcolor and Update examples

This commit is contained in:
vcaesar 2017-09-14 22:47:21 +08:00
parent 979a569eda
commit 6d2317ee69
4 changed files with 26 additions and 0 deletions

View File

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

View File

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

View File

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

View File

@ -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
}
/*
___________ ____ _______ .__ __. .___________.
| ____\ \ / / | ____|| \ | | | |