Update Screen

This commit is contained in:
vCaesar 2016-11-12 22:45:42 +08:00
parent a30a5fd1e3
commit 8d56089f69
3 changed files with 39 additions and 15 deletions

2
doc.md
View File

@ -249,6 +249,8 @@ robotgo.ScrollMouse(50, "down")
Gets part or all of the screen. Gets part or all of the screen.
Capture_Screen Returns a go struct
####Arguments: ####Arguments:
x (optional) x (optional)

View File

@ -46,12 +46,12 @@ import (
*/ */
type Bit_map struct { type Bit_map struct {
ImageBuffer *C.uint8_t ImageBuffer *uint8
Width C.size_t Width int
Height C.size_t Height int
Bytewidth C.size_t Bytewidth int
BitsPerPixel C.uint8_t BitsPerPixel uint8
BytesPerPixel C.uint8_t BytesPerPixel uint8
} }
func GetPixelColor(x, y int) string { func GetPixelColor(x, y int) string {
@ -64,10 +64,10 @@ func GetPixelColor(x, y int) string {
return gcolor return gcolor
} }
func GetScreenSize() (C.size_t, C.size_t) { func GetScreenSize() (int, int) {
size := C.aGetScreenSize() size := C.aGetScreenSize()
// Println("...", size, size.width) // Println("...", size, size.width)
return size.width, size.height return int(size.width), int(size.height)
} }
func GetXDisplayName() string { func GetXDisplayName() string {
@ -110,16 +110,36 @@ func CaptureScreen(args ...int) C.MMBitmapRef {
return bit return bit
} }
func Capture_Screen(x, y, w, h C.size_t) Bit_map { func Capture_Screen(args ...int) Bit_map {
var x C.size_t
var y C.size_t
var w C.size_t
var h C.size_t
Try(func() {
x = C.size_t(args[0])
y = C.size_t(args[1])
w = C.size_t(args[2])
h = C.size_t(args[3])
}, func(e interface{}) {
// Println("err:::", e)
x = 0
y = 0
//Get screen size.
var displaySize C.MMSize
displaySize = C.getMainDisplaySize()
w = displaySize.width
h = displaySize.height
})
bit := C.aCaptureScreen(x, y, w, h) bit := C.aCaptureScreen(x, y, w, h)
// Println("...", bit) // Println("...", bit)
bit_map := Bit_map{ bit_map := Bit_map{
ImageBuffer: bit.imageBuffer, ImageBuffer: (*uint8)(bit.imageBuffer),
Width: bit.width, Width: int(bit.width),
Height: bit.height, Height: int(bit.height),
Bytewidth: bit.bytewidth, Bytewidth: int(bit.bytewidth),
BitsPerPixel: bit.bitsPerPixel, BitsPerPixel: uint8(bit.bitsPerPixel),
BytesPerPixel: bit.bytesPerPixel, BytesPerPixel: uint8(bit.bytesPerPixel),
} }
return bit_map return bit_map

View File

@ -264,6 +264,8 @@ robotgo.ScrollMouse(50, "down")
获取部分或者全部屏幕 获取部分或者全部屏幕
Gets part or all of the screen. Gets part or all of the screen.
Capture_Screen Returns a go struct
####参数: ####参数:
x (optional) x (optional)