mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43:55 +00:00
add func ToBitmap Fixed #90
This commit is contained in:
parent
c98cdf26dc
commit
b5676fa258
13
robotgo.go
13
robotgo.go
@ -820,6 +820,19 @@ func TostringBitmap(bit C.MMBitmapRef) *C.char {
|
|||||||
return strBit
|
return strBit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ToBitmap trans C.MMBitmapRef to Bitmap
|
||||||
|
func ToBitmap(bit C.MMBitmapRef) Bitmap {
|
||||||
|
bitmap := Bitmap{
|
||||||
|
ImageBuffer: (*uint8)(bit.imageBuffer),
|
||||||
|
Width: int(bit.width),
|
||||||
|
Height: int(bit.height),
|
||||||
|
Bytewidth: int(bit.bytewidth),
|
||||||
|
BitsPerPixel: uint8(bit.bitsPerPixel),
|
||||||
|
BytesPerPixel: uint8(bit.bytesPerPixel),
|
||||||
|
}
|
||||||
|
return bitmap
|
||||||
|
}
|
||||||
|
|
||||||
// GetPortion get portion
|
// GetPortion get portion
|
||||||
func GetPortion(bit C.MMBitmapRef, x, y, w, h C.size_t) C.MMBitmapRef {
|
func GetPortion(bit C.MMBitmapRef, x, y, w, h C.size_t) C.MMBitmapRef {
|
||||||
var rect C.MMRect
|
var rect C.MMRect
|
||||||
|
17
test/bitmap.go
Normal file
17
test/bitmap.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/go-vgo/robotgo"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
var bitmap robotgo.Bitmap
|
||||||
|
bit := robotgo.OpenBitmap("./test.bmp", 2)
|
||||||
|
bitmap = robotgo.ToBitmap(bit)
|
||||||
|
fmt.Println("...type", reflect.TypeOf(bit), reflect.TypeOf(bitmap))
|
||||||
|
|
||||||
|
}
|
BIN
test/test.bmp
Normal file
BIN
test/test.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Loading…
Reference in New Issue
Block a user