mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-29 21:43:55 +00:00
Update README.md and bytewidth C type
This commit is contained in:
parent
c0ef98e712
commit
c395a0dcd6
@ -270,7 +270,7 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
#### [Bitmap](https://github.com/go-vgo/robotgo/blob/master/examples/bitmap/main.go)
|
||||
#### [Bitmap](https://github.com/vcaesar/bitmap/blob/master/examples/main.go)
|
||||
|
||||
```Go
|
||||
package main
|
||||
@ -370,7 +370,7 @@ func opencv() {
|
||||
}
|
||||
```
|
||||
|
||||
#### [Event](https://github.com/go-vgo/robotgo/blob/master/examples/gohook/main.go)
|
||||
#### [Event](https://github.com/robotn/gohook/blob/master/examples/main.go)
|
||||
|
||||
```Go
|
||||
package main
|
||||
|
@ -11,7 +11,7 @@ struct _MMBitmap {
|
||||
uint8_t *imageBuffer; /* Pixels stored in Quad I format; */
|
||||
int32_t width; /* Never 0, unless image is NULL. */
|
||||
int32_t height; /* Never 0, unless image is NULL. */
|
||||
size_t bytewidth; /* The aligned width (width + padding). */
|
||||
int32_t bytewidth; /* The aligned width (width + padding). */
|
||||
uint8_t bitsPerPixel; /* Should be either 24 or 32. */
|
||||
uint8_t bytesPerPixel; /* For convenience; should be bitsPerPixel / 8. */
|
||||
};
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <string.h>
|
||||
|
||||
MMBitmapRef createMMBitmap_c(uint8_t *buffer, int32_t width, int32_t height,
|
||||
size_t bytewidth, uint8_t bitsPerPixel, uint8_t bytesPerPixel
|
||||
int32_t bytewidth, uint8_t bitsPerPixel, uint8_t bytesPerPixel
|
||||
) {
|
||||
MMBitmapRef bitmap = malloc(sizeof(MMBitmap));
|
||||
if (bitmap == NULL) { return NULL; }
|
||||
|
@ -375,7 +375,7 @@ func ToCBitmap(bit Bitmap) CBitmap {
|
||||
(*C.uint8_t)(bit.ImgBuf),
|
||||
C.int32_t(bit.Width),
|
||||
C.int32_t(bit.Height),
|
||||
C.size_t(bit.Bytewidth),
|
||||
C.int32_t(bit.Bytewidth),
|
||||
C.uint8_t(bit.BitsPixel),
|
||||
C.uint8_t(bit.BytesPerPixel),
|
||||
)
|
||||
|
@ -35,8 +35,9 @@ MMBitmapRef copyMMBitmapFromDisplayInRect(MMRectInt32 rect, int32_t display_id)
|
||||
buffer = malloc(bufferSize);
|
||||
CFDataGetBytes(imageData, CFRangeMake(0, bufferSize), buffer);
|
||||
|
||||
bitmap = createMMBitmap_c(buffer, CGImageGetWidth(image), CGImageGetHeight(image),
|
||||
CGImageGetBytesPerRow(image), CGImageGetBitsPerPixel(image),CGImageGetBitsPerPixel(image) / 8);
|
||||
bitmap = createMMBitmap_c(buffer,
|
||||
CGImageGetWidth(image), CGImageGetHeight(image), CGImageGetBytesPerRow(image),
|
||||
CGImageGetBitsPerPixel(image), CGImageGetBitsPerPixel(image) / 8);
|
||||
|
||||
CFRelease(imageData);
|
||||
CGImageRelease(image);
|
||||
|
Loading…
Reference in New Issue
Block a user