Remove bitmap

This commit is contained in:
vcaesar 2017-08-05 00:45:54 +08:00
parent a262c68f42
commit 1a6054612a
6 changed files with 187 additions and 209 deletions

View File

@ -36,29 +36,22 @@ This is a work in progress.
## Requirements:
Now, Please make sure Golang, GCC, zlib and libpng is installed correctly before installing RobotGo.
Now, Please make sure Golang, GCC is installed correctly before installing RobotGo.
### ALL:
```
Golang
GCC
zlib & libpng (bitmap)
```
#### For Mac OS X:
Xcode Command Line Tools
```
brew install libpng
brew install homebrew/dupes/zlib
Xcode Command Line Tools
```
#### For Windows:
```
MinGW or other GCC
zlib & libpng (bitmap need it.)
```
##### [Zlib & libpng Windows32 GCC's Course](https://github.com/go-vgo/Mingw32)
##### [Download include zlib & libpng Windows64 GCC](https://github.com/go-vgo/Mingw)
#### For everything else:
```
@ -76,8 +69,7 @@ xcb, xkb, libxkbcommon
sudo apt-get install gcc libc6-dev
sudo apt-get install libx11-dev
sudo apt-get install xorg-dev
sudo apt-get install libxtst-dev libpng++-dev
sudo apt-get install xorg-dev
sudo apt-get install xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev
sudo apt-get install libxkbcommon-dev
@ -91,8 +83,6 @@ sudo apt-get install xclip
```yml
sudo dnf install libxkbcommon-devel libXtst-devel libxkbcommon-x11-devel xorg-x11-xkb-utils-devel
sudo dnf install libpng-devel
sudo dnf install xsel
sudo dnf install xclip
```
@ -103,8 +93,6 @@ go get github.com/go-vgo/robotgo
```
It's that easy!
png.h: No such file or directory? Please see [issues/47](https://github.com/go-vgo/robotgo/issues/47).
## Update:
```
go get -u github.com/go-vgo/robotgo
@ -174,7 +162,7 @@ func main() {
}
```
#### [Bitmap](https://github.com/go-vgo/robotgo/blob/master/examples/bitmap/mian.go)
<!-- #### [Bitmap](https://github.com/go-vgo/robotgo/blob/master/examples/bitmap/mian.go)
```Go
package main
@ -194,7 +182,7 @@ func main() {
robotgo.SaveBitmap(bitmap, "test.png")
}
```
``` -->
#### [Event](https://github.com/go-vgo/robotgo/blob/master/examples/event/main.go)

View File

@ -34,28 +34,21 @@ QQ 群: 595877611
## Requirements:
环境要求:
在安装 RobotGo 之前, 请确保 Golang、GCC、zlib 和 libpng 被正确安装
在安装 RobotGo 之前, 请确保 Golang、GCC 被正确安装
### ALL:
```
Golang
GCC
zlib & libpng (bitmap)
```
#### For Mac OS X:
Xcode Command Line Tools
```
brew install libpng
brew install homebrew/dupes/zlib
Xcode Command Line Tools
```
#### For Windows:
```
MinGW or other GCC
zlib & libpng (bitmap 依赖)
```
##### [Zlib & libpng Windows32 GCC 教程](https://github.com/go-vgo/Mingw32)
##### [下载包含 zlib 和 libpng 的 64位 MinGW](https://github.com/go-vgo/Mingw)
#### For everything else (Linux 等其他系统):
```
@ -73,9 +66,7 @@ xcb, xkb, libxkbcommon
sudo apt-get install gcc libc6-dev
sudo apt-get install libx11-dev
sudo apt-get install xorg-dev
sudo apt-get install libxtst-dev libpng++-dev
sudo apt-get install xorg-dev
sudo apt-get install xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev
sudo apt-get install libxkbcommon-dev
@ -90,8 +81,6 @@ sudo apt-get install xclip
```yml
sudo dnf install libxkbcommon-devel libXtst-devel libxkbcommon-x11-devel xorg-x11-xkb-utils-devel
sudo dnf install libpng-devel
sudo dnf install xsel
sudo dnf install xclip
```
@ -99,9 +88,7 @@ sudo dnf install xclip
```
go get github.com/go-vgo/robotgo
```
It's that easy!
png.h: No such file or directory? Please see [issues/47](https://github.com/go-vgo/robotgo/issues/47).
It's that easy!
## Update:
```
@ -172,7 +159,7 @@ func main() {
}
```
#### [位图](https://github.com/go-vgo/robotgo/blob/master/examples/bitmap/mian.go)
<!-- #### [位图](https://github.com/go-vgo/robotgo/blob/master/examples/bitmap/mian.go)
```Go
package main
@ -192,7 +179,7 @@ func main() {
robotgo.SaveBitmap(bitmap, "test.png")
}
```
``` -->
#### [事件](https://github.com/go-vgo/robotgo/blob/master/examples/event/main.go)

View File

@ -12,7 +12,7 @@ dependencies:
# - sudo apt-get install libghc6-x11-dev
# - sudo apt-get install libgl1-mesa-swx11-dev
- sudo apt-get install xorg-dev
- sudo apt-get install libxtst-dev libpng++-dev
# - sudo apt-get install libxtst-dev libpng++-dev
# Event:
- sudo apt-get install xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev
- sudo apt-get install libxkbcommon-dev

View File

@ -30,29 +30,29 @@ func main() {
bitmap := robotgo.CaptureScreen(100, 200, 30, 40)
fmt.Println("CaptureScreen...", bitmap)
// searches for needle in bitmap
fx, fy := robotgo.FindBitmap(bitmap)
fmt.Println("FindBitmap------", fx, fy)
// // searches for needle in bitmap
// fx, fy := robotgo.FindBitmap(bitmap)
// fmt.Println("FindBitmap------", fx, fy)
// returns new bitmap object created from a portion of another
bitpos := robotgo.GetPortion(bitmap, 10, 10, 11, 10)
fmt.Println(bitpos)
// // returns new bitmap object created from a portion of another
// bitpos := robotgo.GetPortion(bitmap, 10, 10, 11, 10)
// fmt.Println(bitpos)
// creates bitmap from string by bitmap
bitstr := robotgo.TostringBitmap(bitmap)
fmt.Println("bitstr...", bitstr)
// // creates bitmap from string by bitmap
// bitstr := robotgo.TostringBitmap(bitmap)
// fmt.Println("bitstr...", bitstr)
// sbitmap := robotgo.BitmapFromstring(bitstr, 2)
// fmt.Println("...", sbitmap)
// // sbitmap := robotgo.BitmapFromstring(bitstr, 2)
// // fmt.Println("...", sbitmap)
// saves image to absolute filepath in the given format
robotgo.SaveBitmap(bitmap, "test.png")
robotgo.SaveBitmap(bitmap, "test31.tif", 1)
// // saves image to absolute filepath in the given format
// robotgo.SaveBitmap(bitmap, "test.png")
// robotgo.SaveBitmap(bitmap, "test31.tif", 1)
// convert image
robotgo.Convert("test.png", "test.tif")
// // convert image
// robotgo.Convert("test.png", "test.tif")
// open image bitmap
openbit := robotgo.OpenBitmap("test.tif")
fmt.Println("openBitmap...", openbit)
// // open image bitmap
// openbit := robotgo.OpenBitmap("test.tif")
// fmt.Println("openBitmap...", openbit)
}

View File

@ -124,45 +124,45 @@ func screen() {
}
func bitmap() {
////////////////////////////////////////////////////////////////////////////////
// Bitmap
////////////////////////////////////////////////////////////////////////////////
// func bitmap() {
// ////////////////////////////////////////////////////////////////////////////////
// // Bitmap
// ////////////////////////////////////////////////////////////////////////////////
// gets all of the screen
abitMap := robotgo.CaptureScreen()
fmt.Println("abitMap...", abitMap)
// // gets all of the screen
// abitMap := robotgo.CaptureScreen()
// fmt.Println("abitMap...", abitMap)
// gets part of the screen
bitmap := robotgo.CaptureScreen(100, 200, 30, 40)
fmt.Println("CaptureScreen...", bitmap)
// // gets part of the screen
// bitmap := robotgo.CaptureScreen(100, 200, 30, 40)
// fmt.Println("CaptureScreen...", bitmap)
// searches for needle in bitmap
fx, fy := robotgo.FindBitmap(bitmap)
fmt.Println("FindBitmap------", fx, fy)
// // searches for needle in bitmap
// fx, fy := robotgo.FindBitmap(bitmap)
// fmt.Println("FindBitmap------", fx, fy)
// returns new bitmap object created from a portion of another
bitpos := robotgo.GetPortion(bitmap, 10, 10, 11, 10)
fmt.Println(bitpos)
// // returns new bitmap object created from a portion of another
// bitpos := robotgo.GetPortion(bitmap, 10, 10, 11, 10)
// fmt.Println(bitpos)
// creates bitmap from string by bitmap
bitstr := robotgo.TostringBitmap(bitmap)
fmt.Println("bitstr...", bitstr)
// // creates bitmap from string by bitmap
// bitstr := robotgo.TostringBitmap(bitmap)
// fmt.Println("bitstr...", bitstr)
// sbitmap := robotgo.BitmapFromstring(bitstr, 2)
// fmt.Println("...", sbitmap)
// // sbitmap := robotgo.BitmapFromstring(bitstr, 2)
// // fmt.Println("...", sbitmap)
// saves image to absolute filepath in the given format
robotgo.SaveBitmap(bitmap, "test.png")
robotgo.SaveBitmap(bitmap, "test31.tif", 1)
// // saves image to absolute filepath in the given format
// robotgo.SaveBitmap(bitmap, "test.png")
// robotgo.SaveBitmap(bitmap, "test31.tif", 1)
// convert image
robotgo.Convert("test.png", "test.tif")
// // convert image
// robotgo.Convert("test.png", "test.tif")
// open image bitmap
openbit := robotgo.OpenBitmap("test.tif")
fmt.Println("openBitmap...", openbit)
}
// // open image bitmap
// openbit := robotgo.OpenBitmap("test.tif")
// fmt.Println("openBitmap...", openbit)
// }
func event() {
////////////////////////////////////////////////////////////////////////////////
@ -285,7 +285,7 @@ func main() {
// Read the screen
screen()
// Bitmap and image processing
bitmap()
// bitmap()
// Global event listener
event()
// Window Handle and progress

View File

@ -25,18 +25,21 @@ package robotgo
/*
//#if defined(IS_MACOSX)
#cgo darwin CFLAGS: -x objective-c -Wno-deprecated-declarations -I/usr/local/opt/libpng/include -I/usr/local/opt/zlib/include
#cgo darwin LDFLAGS: -framework Cocoa -framework OpenGL -framework IOKit -framework Carbon -framework CoreFoundation -L/usr/local/opt/libpng/lib -lpng -L/usr/local/opt/zlib/lib -lz
#cgo darwin LDFLAGS: -framework Cocoa -framework OpenGL -framework IOKit -framework Carbon -framework CoreFoundation
// -L/usr/local/opt/libpng/lib -lpng -L/usr/local/opt/zlib/lib -lz
//#elif defined(USE_X11)
// drop -std=c11
#cgo linux CFLAGS:-I/usr/src
#cgo linux LDFLAGS:-L/usr/src -lpng -lz -lX11 -lXtst -lX11-xcb -lxcb -lxcb-xkb -lxkbcommon -lxkbcommon-x11 -lm
#cgo linux LDFLAGS:-L/usr/src -lX11 -lXtst -lX11-xcb -lxcb -lxcb-xkb -lxkbcommon -lxkbcommon-x11 -lm
// -lpng -lz
//#endif
#cgo windows LDFLAGS: -lgdi32 -luser32 -lpng -lz
#cgo windows LDFLAGS: -lgdi32 -luser32
// -lpng -lz
//#include <AppKit/NSEvent.h>
#include "screen/goScreen.h"
#include "mouse/goMouse.h"
#include "key/goKey.h"
#include "bitmap/goBitmap.h"
// #include "bitmap/goBitmap.h"
#include "event/goEvent.h"
#include "window/goWindow.h"
*/
@ -573,137 +576,137 @@ func SetKeyboardDelay(x int) {
|______/ |__| |__| |__| |__| /__/ \__\ | _|
*/
// FindBitmap find the bitmap
func FindBitmap(args ...interface{}) (int, int) {
var bit C.MMBitmapRef
bit = args[0].(C.MMBitmapRef)
// // FindBitmap find the bitmap
// func FindBitmap(args ...interface{}) (int, int) {
// var bit C.MMBitmapRef
// bit = args[0].(C.MMBitmapRef)
var rect C.MMRect
Try(func() {
rect.origin.x = C.size_t(args[1].(int))
rect.origin.y = C.size_t(args[2].(int))
rect.size.width = C.size_t(args[3].(int))
rect.size.height = C.size_t(args[4].(int))
}, func(e interface{}) {
// fmt.Println("err:::", e)
// rect.origin.x = x
// rect.origin.y = y
// rect.size.width = w
// rect.size.height = h
})
// var rect C.MMRect
// Try(func() {
// rect.origin.x = C.size_t(args[1].(int))
// rect.origin.y = C.size_t(args[2].(int))
// rect.size.width = C.size_t(args[3].(int))
// rect.size.height = C.size_t(args[4].(int))
// }, func(e interface{}) {
// // fmt.Println("err:::", e)
// // rect.origin.x = x
// // rect.origin.y = y
// // rect.size.width = w
// // rect.size.height = h
// })
pos := C.aFindBitmap(bit, rect)
// fmt.Println("pos----", pos)
return int(pos.x), int(pos.y)
}
// pos := C.aFindBitmap(bit, rect)
// // fmt.Println("pos----", pos)
// return int(pos.x), int(pos.y)
// }
// OpenBitmap open the bitmap
func OpenBitmap(args ...interface{}) C.MMBitmapRef {
path := C.CString(args[0].(string))
var mtype C.uint16_t
Try(func() {
mtype = C.uint16_t(args[1].(int))
}, func(e interface{}) {
// fmt.Println("err:::", e)
mtype = 1
})
bit := C.bitmap_open(path, mtype)
defer C.free(unsafe.Pointer(path))
// fmt.Println("opening...", bit)
return bit
// defer C.free(unsafe.Pointer(path))
}
// SaveBitmap save the bitmap
func SaveBitmap(args ...interface{}) string {
var mtype C.uint16_t
Try(func() {
mtype = C.uint16_t(args[2].(int))
}, func(e interface{}) {
// fmt.Println("err:::", e)
mtype = 1
})
path := C.CString(args[1].(string))
savebit := C.bitmap_save(args[0].(C.MMBitmapRef), path, mtype)
// fmt.Println("saved...", savebit)
// return bit
defer C.free(unsafe.Pointer(path))
return C.GoString(savebit)
}
// func SaveBitmap(bit C.MMBitmapRef, gpath string, mtype C.MMImageType) {
// path := C.CString(gpath)
// savebit := C.aSaveBitmap(bit, path, mtype)
// fmt.Println("saving...", savebit)
// // return bit
// // OpenBitmap open the bitmap
// func OpenBitmap(args ...interface{}) C.MMBitmapRef {
// path := C.CString(args[0].(string))
// var mtype C.uint16_t
// Try(func() {
// mtype = C.uint16_t(args[1].(int))
// }, func(e interface{}) {
// // fmt.Println("err:::", e)
// mtype = 1
// })
// bit := C.bitmap_open(path, mtype)
// defer C.free(unsafe.Pointer(path))
// // fmt.Println("opening...", bit)
// return bit
// // defer C.free(unsafe.Pointer(path))
// }
// TostringBitmap tostring bitmap
func TostringBitmap(bit C.MMBitmapRef) *C.char {
// str_bit := C.aTostringBitmap(bit)
strBit := C.aTostringBitmap(bit)
// fmt.Println("...", str_bit)
// return str_bit
return strBit
}
// // SaveBitmap save the bitmap
// func SaveBitmap(args ...interface{}) string {
// var mtype C.uint16_t
// Try(func() {
// mtype = C.uint16_t(args[2].(int))
// }, func(e interface{}) {
// // fmt.Println("err:::", e)
// mtype = 1
// })
// GetPortion get portion
func GetPortion(bit C.MMBitmapRef, x, y, w, h C.size_t) C.MMBitmapRef {
var rect C.MMRect
rect.origin.x = x
rect.origin.y = y
rect.size.width = w
rect.size.height = h
// path := C.CString(args[1].(string))
// savebit := C.bitmap_save(args[0].(C.MMBitmapRef), path, mtype)
// // fmt.Println("saved...", savebit)
// // return bit
// defer C.free(unsafe.Pointer(path))
pos := C.aGetPortion(bit, rect)
return pos
}
// return C.GoString(savebit)
// }
// Convert convert bitmap
func Convert(args ...interface{}) {
var mtype int
Try(func() {
mtype = args[2].(int)
}, func(e interface{}) {
// fmt.Println("err:::", e)
mtype = 1
})
//C.CString()
opath := args[0].(string)
spath := args[1].(string)
bitmap := OpenBitmap(opath)
// fmt.Println("a----", bit_map)
SaveBitmap(bitmap, spath, mtype)
}
// // func SaveBitmap(bit C.MMBitmapRef, gpath string, mtype C.MMImageType) {
// // path := C.CString(gpath)
// // savebit := C.aSaveBitmap(bit, path, mtype)
// // fmt.Println("saving...", savebit)
// // // return bit
// // // defer C.free(unsafe.Pointer(path))
// // }
// FreeBitmap free and dealloc bitmap
func FreeBitmap(bitmap C.MMBitmapRef) {
// C.destroyMMBitmap(bitmap)
C.bitmap_dealloc(bitmap)
}
// // TostringBitmap tostring bitmap
// func TostringBitmap(bit C.MMBitmapRef) *C.char {
// // str_bit := C.aTostringBitmap(bit)
// strBit := C.aTostringBitmap(bit)
// // fmt.Println("...", str_bit)
// // return str_bit
// return strBit
// }
// ReadBitmap returns false and sets error if |bitmap| is NULL
func ReadBitmap(bitmap C.MMBitmapRef) bool {
abool := C.bitmap_ready(bitmap)
gbool := bool(abool)
return gbool
}
// // GetPortion get portion
// func GetPortion(bit C.MMBitmapRef, x, y, w, h C.size_t) C.MMBitmapRef {
// var rect C.MMRect
// rect.origin.x = x
// rect.origin.y = y
// rect.size.width = w
// rect.size.height = h
// CopyBitpb copy bitmap to pasteboard
func CopyBitpb(bitmap C.MMBitmapRef) bool {
abool := C.bitmap_copy_to_pboard(bitmap)
gbool := bool(abool)
return gbool
}
// pos := C.aGetPortion(bit, rect)
// return pos
// }
// DeepCopyBit deep copy bitmap
func DeepCopyBit(bitmap C.MMBitmapRef) C.MMBitmapRef {
bit := C.bitmap_deepcopy(bitmap)
return bit
}
// // Convert convert bitmap
// func Convert(args ...interface{}) {
// var mtype int
// Try(func() {
// mtype = args[2].(int)
// }, func(e interface{}) {
// // fmt.Println("err:::", e)
// mtype = 1
// })
// //C.CString()
// opath := args[0].(string)
// spath := args[1].(string)
// bitmap := OpenBitmap(opath)
// // fmt.Println("a----", bit_map)
// SaveBitmap(bitmap, spath, mtype)
// }
// // FreeBitmap free and dealloc bitmap
// func FreeBitmap(bitmap C.MMBitmapRef) {
// // C.destroyMMBitmap(bitmap)
// C.bitmap_dealloc(bitmap)
// }
// // ReadBitmap returns false and sets error if |bitmap| is NULL
// func ReadBitmap(bitmap C.MMBitmapRef) bool {
// abool := C.bitmap_ready(bitmap)
// gbool := bool(abool)
// return gbool
// }
// // CopyBitpb copy bitmap to pasteboard
// func CopyBitpb(bitmap C.MMBitmapRef) bool {
// abool := C.bitmap_copy_to_pboard(bitmap)
// gbool := bool(abool)
// return gbool
// }
// // DeepCopyBit deep copy bitmap
// func DeepCopyBit(bitmap C.MMBitmapRef) C.MMBitmapRef {
// bit := C.bitmap_deepcopy(bitmap)
// return bit
// }
/*
___________ ____ _______ .__ __. .___________.