diff --git a/README.md b/README.md index e26fa67..cae54a6 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,9 @@ import ( func main() { bitmap := robotgo.CaptureScreen(10, 20, 30, 40) + // use `defer robotgo.FreeBitmap(bit)` to free the bitmap + defer robotgo.FreeBitmap(bitmap) + fmt.Println("...", bitmap) fx, fy := robotgo.FindBitmap(bitmap) diff --git a/README_zh.md b/README_zh.md index 828a35c..b1279a2 100644 --- a/README_zh.md +++ b/README_zh.md @@ -181,6 +181,8 @@ import ( func main() { bitmap := robotgo.CaptureScreen(10, 20, 30, 40) + // use `defer robotgo.FreeBitmap(bit)` to free the bitmap + defer robotgo.FreeBitmap(bitmap) fmt.Println("...", bitmap) fx, fy := robotgo.FindBitmap(bitmap) diff --git a/examples/README.md b/examples/README.md index 7d3bbf2..9e6f5d8 100644 --- a/examples/README.md +++ b/examples/README.md @@ -87,6 +87,8 @@ import ( func main() { bitmap := robotgo.CaptureScreen(10, 20, 30, 40) + // use `defer robotgo.FreeBitmap(bit)` to free the bitmap + defer robotgo.FreeBitmap(bitmap) fmt.Println("...", bitmap) fx, fy := robotgo.FindBitmap(bitmap) diff --git a/robotgo.go b/robotgo.go index 86fee72..d0148e9 100644 --- a/robotgo.go +++ b/robotgo.go @@ -254,7 +254,7 @@ func GetXDisplayName() string { return gname } -// CaptureScreen capture the screen return bitmap(c struct) +// CaptureScreen capture the screen return bitmap(c struct), // use `defer robotgo.FreeBitmap(bitmap)` to free the bitmap func CaptureScreen(args ...int) C.MMBitmapRef { var x, y, w, h C.size_t @@ -798,7 +798,7 @@ func internalFindBitmap(bit, sbit C.MMBitmapRef, tolerance float64) (int, int) { // // |tolerance| should be in the range 0.0f - 1.0f, denoting how closely the // colors in the bitmaps need to match, with 0 being exact and 1 being any. -// +// // This method only automatically free the internal bitmap, // use `defer robotgo.FreeBitmap(bit)` to free the bitmap func FindBitmap(bit C.MMBitmapRef, args ...interface{}) (int, int) {