mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13: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
|
```Go
|
||||||
package main
|
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
|
```Go
|
||||||
package main
|
package main
|
||||||
|
@ -11,7 +11,7 @@ struct _MMBitmap {
|
|||||||
uint8_t *imageBuffer; /* Pixels stored in Quad I format; */
|
uint8_t *imageBuffer; /* Pixels stored in Quad I format; */
|
||||||
int32_t width; /* Never 0, unless image is NULL. */
|
int32_t width; /* Never 0, unless image is NULL. */
|
||||||
int32_t height; /* 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 bitsPerPixel; /* Should be either 24 or 32. */
|
||||||
uint8_t bytesPerPixel; /* For convenience; should be bitsPerPixel / 8. */
|
uint8_t bytesPerPixel; /* For convenience; should be bitsPerPixel / 8. */
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
MMBitmapRef createMMBitmap_c(uint8_t *buffer, int32_t width, int32_t height,
|
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));
|
MMBitmapRef bitmap = malloc(sizeof(MMBitmap));
|
||||||
if (bitmap == NULL) { return NULL; }
|
if (bitmap == NULL) { return NULL; }
|
||||||
|
@ -375,7 +375,7 @@ func ToCBitmap(bit Bitmap) CBitmap {
|
|||||||
(*C.uint8_t)(bit.ImgBuf),
|
(*C.uint8_t)(bit.ImgBuf),
|
||||||
C.int32_t(bit.Width),
|
C.int32_t(bit.Width),
|
||||||
C.int32_t(bit.Height),
|
C.int32_t(bit.Height),
|
||||||
C.size_t(bit.Bytewidth),
|
C.int32_t(bit.Bytewidth),
|
||||||
C.uint8_t(bit.BitsPixel),
|
C.uint8_t(bit.BitsPixel),
|
||||||
C.uint8_t(bit.BytesPerPixel),
|
C.uint8_t(bit.BytesPerPixel),
|
||||||
)
|
)
|
||||||
|
@ -35,8 +35,9 @@ MMBitmapRef copyMMBitmapFromDisplayInRect(MMRectInt32 rect, int32_t display_id)
|
|||||||
buffer = malloc(bufferSize);
|
buffer = malloc(bufferSize);
|
||||||
CFDataGetBytes(imageData, CFRangeMake(0, bufferSize), buffer);
|
CFDataGetBytes(imageData, CFRangeMake(0, bufferSize), buffer);
|
||||||
|
|
||||||
bitmap = createMMBitmap_c(buffer, CGImageGetWidth(image), CGImageGetHeight(image),
|
bitmap = createMMBitmap_c(buffer,
|
||||||
CGImageGetBytesPerRow(image), CGImageGetBitsPerPixel(image),CGImageGetBitsPerPixel(image) / 8);
|
CGImageGetWidth(image), CGImageGetHeight(image), CGImageGetBytesPerRow(image),
|
||||||
|
CGImageGetBitsPerPixel(image), CGImageGetBitsPerPixel(image) / 8);
|
||||||
|
|
||||||
CFRelease(imageData);
|
CFRelease(imageData);
|
||||||
CGImageRelease(image);
|
CGImageRelease(image);
|
||||||
|
Loading…
Reference in New Issue
Block a user