Skip to content

Commit

Permalink
Merge pull request #466 from go-vgo/bitmap-pr
Browse files Browse the repository at this point in the history
Update README.md and bytewidth C type
  • Loading branch information
vcaesar authored Feb 9, 2022
2 parents 5d651eb + c395a0d commit 45b85e1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion base/MMBitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
};
Expand Down
2 changes: 1 addition & 1 deletion base/bitmap_free_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
2 changes: 1 addition & 1 deletion robotgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand Down
5 changes: 3 additions & 2 deletions screen/screengrab_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 45b85e1

Please sign in to comment.