Documentation ¶
Index ¶
- Constants
- Variables
- func Clone(img image.Image) *image.NRGBA
- func Cmd(cmd string) ([]byte, error)
- func CmdArg(cmd ...string) ([]byte, error)
- func Cmds(x []string)
- func CmpAt(img *image.NRGBA, subimg *image.NRGBA, offX int, offY int, limit int64) int64
- func Decode(r io.Reader) (image.Image, error)
- func Encode(w io.Writer, img image.Image, format Format) error
- func Find(img image.Image, subimg image.Image) (x int, y int, val float64)
- func FindCachedReg(b Bot, tmpl *Tmpl, delay int) (x int, y int, val float64)
- func FindExistImg(b Bot, subimg image.Image, times int, delay int) (x int, y int, val float64)
- func FindExistReg(b Bot, tmpl *Tmpl, times int, delay int) (x int, y int, val float64)
- func FindInTmpl(img image.Image, tmpl *Tmpl) (x int, y int, val float64)
- func FindP(img image.Image, subimg image.Image) (x int, y int, val float64)
- func Fit(img image.Image, width, height int, filter ResampleFilter) *image.NRGBA
- func OpenImage(filename string) (image.Image, error)
- func ReadTagByte(conn io.Reader) ([]byte, error)
- func ReadTagStr(conn io.Reader) (string, error)
- func ReadVLen(conn io.Reader) (int64, error)
- func ReadVTagByte(conn io.Reader) ([]byte, error)
- func Rect(x, y, xp, yp int) image.Rectangle
- func RectAbs(x, y, x2, y2 int) image.Rectangle
- func Resize(img image.Image, width, height int, filter ResampleFilter) *image.NRGBA
- func SaveImage(img image.Image, filename string) (err error)
- func V(level int, v ...interface{})
- func Vf(level int, format string, v ...interface{})
- func Vln(level int, v ...interface{})
- func WriteTagByte(conn io.Writer, tag []byte) (err error)
- func WriteTagStr(conn io.Writer, tag string) (err error)
- func WriteVLen(conn io.Writer, n int64) (err error)
- func WriteVTagByte(conn io.Writer, tag []byte) (err error)
- type Bot
- type CmdInput
- func (i *CmdInput) Click(loc image.Point) (err error)
- func (i *CmdInput) Key(in string, ty KeyAction) (err error)
- func (i *CmdInput) KeyBack() error
- func (i *CmdInput) KeyHome() error
- func (i *CmdInput) KeyPower() error
- func (i *CmdInput) KeySwitch() error
- func (i *CmdInput) Keyevent(in string) (err error)
- func (i *CmdInput) SwipeT(p0, p1 image.Point, time int) (err error)
- func (i *CmdInput) Text(in string) (err error)
- func (i *CmdInput) Touch(loc image.Point, ty KeyAction) (err error)
- type CompStream
- func (c *CompStream) Close() error
- func (c *CompStream) LocalAddr() net.Addr
- func (c *CompStream) Read(p []byte) (n int, err error)
- func (c *CompStream) RemoteAddr() net.Addr
- func (c *CompStream) SetDeadline(t time.Time) error
- func (c *CompStream) SetReadDeadline(t time.Time) error
- func (c *CompStream) SetWriteDeadline(t time.Time) error
- func (c *CompStream) Write(p []byte) (n int, err error)
- type Daemon
- type DiffImgComp
- type DiffImgDeComp
- type FlateStream
- func (c *FlateStream) Close() error
- func (c *FlateStream) LocalAddr() net.Addr
- func (c *FlateStream) Read(p []byte) (n int, err error)
- func (c *FlateStream) RemoteAddr() net.Addr
- func (c *FlateStream) SetDeadline(t time.Time) error
- func (c *FlateStream) SetReadDeadline(t time.Time) error
- func (c *FlateStream) SetWriteDeadline(t time.Time) error
- func (c *FlateStream) Write(p []byte) (n int, err error)
- type Format
- type Input
- type KeyAction
- type LocalBot
- func (b *LocalBot) Adb(parts string) ([]byte, error)
- func (b *LocalBot) GetLastScreencap() image.Image
- func (b *LocalBot) ImgCompLv(lv int)
- func (b *LocalBot) KillApp(app string) (err error)
- func (b *LocalBot) Pipe(parts string) ([]byte, error)
- func (b *LocalBot) PullScreenByte() ([]byte, error)
- func (b *LocalBot) Remap(loc image.Point) image.Point
- func (b *LocalBot) SaveScreen(imagefile string) (err error)
- func (b *LocalBot) Screencap() (img image.Image, err error)
- func (b *LocalBot) ScriptScreen(x0, y0, dx, dy int)
- func (b *LocalBot) SetScale(scale float64)
- func (b *LocalBot) Shell(parts string) ([]byte, error)
- func (b *LocalBot) ShellPipe(p1 io.ReadWriteCloser, cmds string, blocking bool) (*exec.Cmd, error)
- func (b *LocalBot) StartApp(app string) (err error)
- func (b *LocalBot) TriggerScreencap() (err error)
- type Monkey
- func (m *Monkey) Click(loc image.Point) (err error)
- func (m *Monkey) Close() (err error)
- func (m *Monkey) Key(in string, ty KeyAction) (err error)
- func (m *Monkey) KeyBack() error
- func (m *Monkey) KeyHome() error
- func (m *Monkey) KeyPower() error
- func (m *Monkey) KeySwitch() error
- func (m *Monkey) Keyevent(in string) (err error)
- func (m *Monkey) Press(in string) (err error)
- func (m *Monkey) SwipeT(p0, p1 image.Point, dtime int) (err error)
- func (m *Monkey) Tap(loc image.Point) (err error)
- func (m *Monkey) Text(in string) (err error)
- func (m *Monkey) Touch(loc image.Point, ty KeyAction) (err error)
- type RemoteBot
- func (b *RemoteBot) Adb(parts string) ([]byte, error)
- func (b *RemoteBot) Click(loc image.Point) (err error)
- func (b *RemoteBot) GetLastScreencap() image.Image
- func (b *RemoteBot) ImgCompLv(lv int)
- func (b *RemoteBot) Key(in string, ty KeyAction) (err error)
- func (b *RemoteBot) KeyBack() error
- func (b *RemoteBot) KeyHome() error
- func (b *RemoteBot) KeyPower() error
- func (b *RemoteBot) KeySwitch() error
- func (b *RemoteBot) Keyevent(in string) (err error)
- func (b *RemoteBot) KillApp(app string) (err error)
- func (b *RemoteBot) Press(in string) (err error)
- func (b *RemoteBot) PullScreenByte() ([]byte, error)
- func (b *RemoteBot) Remap(loc image.Point) image.Point
- func (b *RemoteBot) SaveScreen(imagefile string) (err error)
- func (b *RemoteBot) Screencap() (img image.Image, err error)
- func (b *RemoteBot) Shell(parts string) ([]byte, error)
- func (b *RemoteBot) ShellPipe(p1 io.ReadWriteCloser, cmds string, blocking bool) (*exec.Cmd, error)
- func (b *RemoteBot) StartApp(app string) (err error)
- func (b *RemoteBot) SwipeT(p0, p1 image.Point, dtime int) (err error)
- func (b *RemoteBot) Tap(loc image.Point) (err error)
- func (b *RemoteBot) Text(in string) (err error)
- func (b *RemoteBot) Touch(loc image.Point, ty KeyAction) (err error)
- func (b *RemoteBot) TriggerScreencap() (err error)
- type ResampleFilter
- type Tmpl
Constants ¶
const ( OP_CLICK = iota OP_SWIPE OP_TOUCH OP_KEY OP_TEXT OP_CAP OP_PULL OP_CMD // no return data OP_SHELL // pipe )
Variables ¶
var ( ErrNotImpl = errors.New("not implemented") ErrNotSupport = errors.New("not supported") ErrTriggerFirst = errors.New("need trigger screencap first") )
var ErrLengthOutOfRange = errors.New("Length Out of Range")
var (
ErrUnsupportedFormat = errors.New("imaging: unsupported image format")
)
var RectAll = image.ZR
var VTagMaxSize uint64 = 128 * 1024 * 1024 // 128MB, should enough for 4k raw image
var Verbosity = 3
Functions ¶
func Encode ¶
Encode writes the image img to w in the specified format (JPEG, PNG, GIF, TIFF or BMP).
func FindExistImg ¶
func FindExistReg ¶
func Fit ¶
Fit scales down the image using the specified resample filter to fit the specified maximum width and height and returns the transformed image.
Supported resample filters: NearestNeighbor, Box, Linear, Hermite, MitchellNetravali, CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine.
Usage example:
dstImage := imaging.Fit(srcImage, 800, 600, imaging.Lanczos)
func Resize ¶
Resize resizes the image to the specified width and height using the specified resampling filter and returns the transformed image. If one of width or height is 0, the image aspect ratio is preserved.
Supported resample filters: NearestNeighbor, Box, Linear, Hermite, MitchellNetravali, CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine.
Usage example:
dstImage := imaging.Resize(srcImage, 800, 600, imaging.Lanczos)
Types ¶
type Bot ¶
type Bot interface { Adb(parts string) ([]byte, error) Shell(parts string) ([]byte, error) // will block untill sh exit ShellPipe(p1 io.ReadWriteCloser, cmds string, blocking bool) (*exec.Cmd, error) TriggerScreencap() (err error) GetLastScreencap() image.Image // cached image Screencap() (img image.Image, err error) PullScreenByte() ([]byte, error) // raw byte (png or RGBA), may not cached SaveScreen(imagefile string) (err error) // ScreenBounds() (image.Rectangle) Remap(loc image.Point) image.Point ImgCompLv(lv int) // input Input StartApp(app string) (err error) KillApp(app string) (err error) }
| on computer | on devices
localBot | adb | shell remoteBot | adb+daemon | shell+daemon all with/without monkey
type CmdInput ¶
type CmdInput struct {
// contains filtered or unexported fields
}
input by cmd command
func NewCmdInput ¶
type CompStream ¶
func NewCompStream ¶
func NewCompStream(conn net.Conn, level int) *CompStream
func (*CompStream) Close ¶
func (c *CompStream) Close() error
func (*CompStream) LocalAddr ¶
func (c *CompStream) LocalAddr() net.Addr
LocalAddr satisfies net.Conn interface
func (*CompStream) RemoteAddr ¶
func (c *CompStream) RemoteAddr() net.Addr
RemoteAddr satisfies net.Conn interface
func (*CompStream) SetDeadline ¶
func (c *CompStream) SetDeadline(t time.Time) error
func (*CompStream) SetReadDeadline ¶
func (c *CompStream) SetReadDeadline(t time.Time) error
func (*CompStream) SetWriteDeadline ¶
func (c *CompStream) SetWriteDeadline(t time.Time) error
type DiffImgComp ¶
type DiffImgComp struct { N int // contains filtered or unexported fields }
func NewDiffImgComp ¶
func NewDiffImgComp(buf *bytes.Buffer, n int) *DiffImgComp
type DiffImgDeComp ¶
type DiffImgDeComp struct {
// contains filtered or unexported fields
}
func NewDiffImgDeComp ¶
func NewDiffImgDeComp() *DiffImgDeComp
type FlateStream ¶
func NewFlateStream ¶
func NewFlateStream(conn net.Conn, level int) *FlateStream
func (*FlateStream) Close ¶
func (c *FlateStream) Close() error
func (*FlateStream) LocalAddr ¶
func (c *FlateStream) LocalAddr() net.Addr
LocalAddr satisfies net.Conn interface
func (*FlateStream) RemoteAddr ¶
func (c *FlateStream) RemoteAddr() net.Addr
RemoteAddr satisfies net.Conn interface
func (*FlateStream) SetDeadline ¶
func (c *FlateStream) SetDeadline(t time.Time) error
func (*FlateStream) SetReadDeadline ¶
func (c *FlateStream) SetReadDeadline(t time.Time) error
func (*FlateStream) SetWriteDeadline ¶
func (c *FlateStream) SetWriteDeadline(t time.Time) error
type Format ¶
type Format int
belows are copy and modify form Grigory Dryapak's Imaging https://github.com/disintegration/imaging
The MIT License (MIT)
Copyright (c) 2012-2018 Grigory Dryapak ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
type Input ¶
type Input interface { Click(loc image.Point) (err error) SwipeT(p0, p1 image.Point, time int) (err error) Touch(loc image.Point, ty KeyAction) (err error) Key(in string, ty KeyAction) (err error) Text(in string) (err error) Keyevent(in string) (err error) KeyHome() error KeyBack() error KeySwitch() error KeyPower() error }
type LocalBot ¶
type LocalBot struct { Dev string Exec string UseSU bool UsePipe bool IsOnDevice bool Local_tmp_path string Adb_tmp_path string // Screen *image.Rectangle TargetScreen *image.Rectangle ScreenBounds image.Rectangle Input // contains filtered or unexported fields }
func NewLocalBot ¶
func NewLocalBotOnDevice ¶
func NewLocalBotOnDevice() *LocalBot
func (*LocalBot) GetLastScreencap ¶
func (*LocalBot) PullScreenByte ¶
func (*LocalBot) SaveScreen ¶
func (*LocalBot) ScriptScreen ¶
func (*LocalBot) TriggerScreencap ¶
type Monkey ¶
input by monkey NOTE: "Accounts" in "Settings" will disappear!! You can NOT setup your accounts!! And can NOT set keyboard app!!
type RemoteBot ¶
type RemoteBot struct { ScreenBounds image.Rectangle FindOnDaemon bool // TODO KeyDelta time.Duration Input // contains filtered or unexported fields }
func (*RemoteBot) GetLastScreencap ¶
func (*RemoteBot) PullScreenByte ¶
func (*RemoteBot) SaveScreen ¶
func (*RemoteBot) TriggerScreencap ¶
type ResampleFilter ¶
ResampleFilter is a resampling filter struct. It can be used to define custom filters.
Supported resample filters: NearestNeighbor, Box, Linear, Hermite, MitchellNetravali, CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine.
General filter recommendations: - Lanczos High-quality resampling filter for photographic images yielding sharp results. It's slower than cubic filters (see below). - CatmullRom A sharp cubic filter. It's a good filter for both upscaling and downscaling if sharp results are needed. - MitchellNetravali A high quality cubic filter that produces smoother results with less ringing artifacts than CatmullRom. - BSpline A good filter if a very smooth output is needed. - Linear Bilinear interpolation filter, produces reasonably good, smooth output. It's faster than cubic filters. - Box Simple and fast averaging filter appropriate for downscaling. When upscaling it's similar to NearestNeighbor. - NearestNeighbor Fastest resampling filter, no antialiasing.
var BSpline ResampleFilter
BSpline is a smooth cubic filter (BC-spline; B=1; C=0).
var Bartlett ResampleFilter
Bartlett is a Bartlett-windowed sinc filter (3 lobes).
var Blackman ResampleFilter
Blackman is a Blackman-windowed sinc filter (3 lobes).
var Box ResampleFilter
Box filter (averaging pixels).
var CatmullRom ResampleFilter
CatmullRom is a Catmull-Rom - sharp cubic filter (BC-spline; B=0; C=0.5).
var Cosine ResampleFilter
Cosine is a Cosine-windowed sinc filter (3 lobes).
var Gaussian ResampleFilter
Gaussian is a Gaussian blurring Filter.
var Hamming ResampleFilter
Hamming is a Hamming-windowed sinc filter (3 lobes).
var Hann ResampleFilter
Hann is a Hann-windowed sinc filter (3 lobes).
var Hermite ResampleFilter
Hermite cubic spline filter (BC-spline; B=0; C=0).
var Lanczos ResampleFilter
Lanczos filter (3 lobes).
var Linear ResampleFilter
Linear filter.
var MitchellNetravali ResampleFilter
MitchellNetravali is Mitchell-Netravali cubic filter (BC-spline; B=1/3; C=1/3).
var NearestNeighbor ResampleFilter
NearestNeighbor is a nearest-neighbor filter (no anti-aliasing).
var Welch ResampleFilter
Welch is a Welch-windowed sinc filter (parabolic window, 3 lobes).