bitmap

package module
v0.10.0-beta3.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

bitmap

Use

package main

import (
  "fmt"

  "github.com/go-vgo/robotgo"
  "github.com/vcaesar/bitmap"
)

func main() {
  bit := robotgo.CaptureScreen(10, 20, 30, 40)
  // use `defer robotgo.FreeBitmap(bit)` to free the bitmap
  defer robotgo.FreeBitmap(bit)

  fmt.Println("bitmap...", bit)
  img := robotgo.ToImage(bit)
  // robotgo.SavePng(img, "test_1.png")
  robotgo.Save(img, "test_1.png")

  bit2 := robotgo.ToCBitmap(robotgo.ImgToBitmap(img))
  fx, fy := bitmap.Find(bit2)
  fmt.Println("FindBitmap------ ", fx, fy)
  robotgo.Move(fx, fy)

  arr := bitmap.FindAll(bit2)
  fmt.Println("Find all bitmap: ", arr)

  fx, fy = bitmap.Find(bit)
  fmt.Println("FindBitmap------ ", fx, fy)

  bitmap.Save(bit, "test.png")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Click

func Click(bit robotgo.CBitmap, args ...interface{})

Click find the bitmap and click

func Convert

func Convert(opath, spath string, args ...int) error

Convert convert the bitmap

bitmap.Convert(opath, spath string, type int)

func CopyToPB

func CopyToPB(bit robotgo.CBitmap) bool

CopyToPB copy bitmap to pasteboard

func Count

func Count(bit, sourceBitmap robotgo.CBitmap, args ...float32) int

Count count of the bitmap

func CountColor

func CountColor(color robotgo.CHex, args ...interface{}) int

CountColor count bitmap color

func CountColorCS

func CountColorCS(color robotgo.CHex, x, y, w, h int, args ...float64) int

CountColorCS count bitmap color by CaptureScreen

func DeepCopy

func DeepCopy(bit robotgo.CBitmap) robotgo.CBitmap

DeepCopy deep copy bitmap to new bitmap

func DeepCopyC

func DeepCopyC(bit C.MMBitmapRef) C.MMBitmapRef

DeepCopyC deep copy bitmap to new bitamp

func Find

func Find(bit robotgo.CBitmap, args ...interface{}) (int, int)

Find find the bitmap's pos in source bitmap

bitmap.Find(bitmap, source_bitmap robotgo.CBitmap, tolerance float64)

|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 FindAll

func FindAll(bit robotgo.CBitmap, args ...interface{}) (posArr []robotgo.Point)

FindAll find the all bitmap

func FindAllColor

func FindAllColor(color robotgo.CHex, args ...interface{}) (posArr []robotgo.Point)

FindAllColor find the all color

func FindColor

func FindColor(color robotgo.CHex, args ...interface{}) (int, int)

FindColor find bitmap color

bitmap.FindColor(color CHex, bitmap robotgo.CBitmap, tolerance float)

func FindColorCS

func FindColorCS(color robotgo.CHex, x, y, w, h int, args ...float64) (int, int)

FindColorCS findcolor by CaptureScreen

func FindPic

func FindPic(path string, args ...interface{}) (int, int)

FindPic finding the image by path

bitmap.FindPic(path string, source_bitmap robotgo.CBitmap, tolerance float64)

This method only automatically free the internal bitmap, use `defer robotgo.FreeBitmap(bit)` to free the bitmap

func FreeArr

func FreeArr(bit ...robotgo.CBitmap)

FreeBitmapArr free and dealloc the C bitmap array

func FreeArrC

func FreeArrC(bit ...C.MMBitmapRef)

FreeArrC free and dealloc the C.MMBitmapRef bitmap array

func FreeMMPointArr

func FreeMMPointArr(pointArray C.MMPointArrayRef)

FreeMMPointArr free MMPoint array

func FromStr

func FromStr(str string) robotgo.CBitmap

FromStr bitmap from string

func FromStrC

func FromStrC(str string) C.MMBitmapRef

FromStrC bitmap from string

func GetColor

func GetColor(bit robotgo.CBitmap, x, y int) C.MMRGBHex

GetColor get the bitmap color

func GetColors

func GetColors(bit robotgo.CBitmap, x, y int) string

GetColors get bitmap color retrun string

func GetPortion

func GetPortion(bit robotgo.CBitmap, x, y, w, h int) robotgo.CBitmap

GetPortion get bitmap portion

func GetSize

func GetSize(imgPath string) (int, int)

GetSize get the image size

func Open

func Open(path string, args ...int) robotgo.CBitmap

Open open the bitmap image return robotgo.CBitmap

func OpenC

func OpenC(gpath string, args ...int) C.MMBitmapRef

OpenC open the bitmap return C.MMBitmapRef

bitmap.Open(path string, type int)

func PointInBounds

func PointInBounds(bit robotgo.CBitmap, x, y int) bool

PointInBounds bitmap point in bounds

func Read

func Read(bit robotgo.CBitmap) bool

Read returns false and sets error if |bitmap| is NULL

func Save

func Save(bit robotgo.CBitmap, gpath string, args ...int) error

Save save the bitmap to image

bitmap.Save(bitmap robotgo.CBitmap, path string, type int)

func SaveCapture

func SaveCapture(spath string, args ...int) error

SaveCapture capture the screen and save to path

func ToBytes

func ToBytes(bit robotgo.CBitmap) []byte

ToBytes saves robotgo.CBitmap to format in bytes

func ToC

func ToC(bit robotgo.Bitmap) C.MMBitmapRef

ToC trans robotgo.Bitmap to C.MMBitmapRef

func ToMMBitmapRef

func ToMMBitmapRef(bit robotgo.CBitmap) C.MMBitmapRef

ToMMBitmapRef trans CBitmap to C.MMBitmapRef

func ToRHex

func ToRHex(hex C.MMRGBHex) robotgo.CHex

ToRHex trans C.MMRGBHex to robotgo.CHex

func ToRobot

func ToRobot(bit C.MMBitmapRef) robotgo.CBitmap

ToRobot trans C.MMBitmapRef to robotgo.CBitmap

func ToThis

func ToThis(bit robotgo.CBitmap) C.MMBitmapRef

ToThis trans robotgo.CBitmap to C.MMBitmapRef

func Tochar

func Tochar(bit robotgo.CBitmap) *C.char

Tochar tostring bitmap to C.char

func Tostring

func Tostring(bit robotgo.CBitmap) string

Tostring tostring bitmap to string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL