mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13:55 +00:00
Update bitmap
This commit is contained in:
parent
8d19ec60b8
commit
9ab2e13551
@ -5,13 +5,12 @@
|
||||
#include "types.h"
|
||||
#include "rgb.h"
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// #if defined(_MSC_VER)
|
||||
// #include "ms_stdint.h"
|
||||
// #else
|
||||
// #include <stdint.h>
|
||||
// #endif
|
||||
// #include <stdint.h>
|
||||
#if defined(_MSC_VER)
|
||||
#include "ms_stdint.h"
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
@ -30,7 +29,7 @@ struct _MMBitmap {
|
||||
|
||||
typedef struct _MMBitmap MMBitmap;
|
||||
typedef MMBitmap *MMBitmapRef;
|
||||
MMBitmapRef bitmap;
|
||||
// MMBitmapRef bitmap;
|
||||
|
||||
/* Creates new MMBitmap with the given values.
|
||||
* Follows the Create Rule (caller is responsible for destroy()'ing object). */
|
||||
@ -62,7 +61,7 @@ MMBitmapRef copyMMBitmapFromPortion(MMBitmapRef source, MMRect rect);
|
||||
/* Get pointer to pixel of MMBitmapRef. No bounds checking is performed (check
|
||||
* yourself before calling this with MMBitmapPointInBounds(). */
|
||||
#define MMRGBColorRefAtPoint(image, x, y) \
|
||||
(MMRGBColor *)(assert(MMBitmapPointInBounds(bitmap, MMPointMake(x, y))), \
|
||||
(MMRGBColor *)(assert(MMBitmapPointInBounds(image, MMPointMake(x, y))), \
|
||||
((image)->imageBuffer) + (((image)->bytewidth * (y)) \
|
||||
+ ((x) * (image)->bytesPerPixel)))
|
||||
|
||||
|
@ -5,7 +5,12 @@
|
||||
#include <stdlib.h> /* For abs() */
|
||||
#include <math.h>
|
||||
#include "inline_keywords.h" /* For H_INLINE */
|
||||
#include <stdint.h>
|
||||
// #include <stdint.h>
|
||||
#if defined(_MSC_VER)
|
||||
#include "ms_stdint.h"
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* RGB colors in MMBitmaps are stored as BGR for convenience in converting
|
||||
|
@ -23,4 +23,4 @@ BitmapObject BitmapObject_FromMMBitmap(MMBitmapRef bitmap);
|
||||
|
||||
// #endif /* PY_BITMAP_CLASS_H */
|
||||
//,MMRect rect
|
||||
MMPoint afindBitmap(MMBitmapRef *needle);
|
||||
MMPoint aFindBitmap(MMBitmapRef bit_map);
|
@ -18,6 +18,26 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
MMPoint aFindBitmap(MMBitmapRef bit_map){
|
||||
// ,MMRect rect
|
||||
MMRect rect;
|
||||
// rect.size.width=10;
|
||||
// rect.size.height=20;
|
||||
// rect.origin.x=10;
|
||||
// rect.origin.y=20;
|
||||
|
||||
float tolerance = 0.0f;
|
||||
MMPoint point;
|
||||
|
||||
tolerance=0.5;
|
||||
|
||||
if (findBitmapInRect(bit_map, bit_map, &point,
|
||||
rect, tolerance) == 0) {
|
||||
return point;
|
||||
}
|
||||
return point;
|
||||
}
|
||||
|
||||
MMBitmapRef aOpenBitmap(char *path){
|
||||
MMImageType type;
|
||||
|
||||
|
@ -222,6 +222,11 @@ func SetKeyboardDelay(x C.size_t) {
|
||||
| |_) | | | | | | | | | / _____ \ | |
|
||||
|______/ |__| |__| |__| |__| /__/ \__\ | _|
|
||||
*/
|
||||
func FindBitmap(bit C.MMBitmapRef) (C.size_t, C.size_t) {
|
||||
pos := C.aFindBitmap(bit)
|
||||
// Println("pos----", pos)
|
||||
return pos.x, pos.y
|
||||
}
|
||||
|
||||
func OpenBitmap(gpath string) C.MMBitmapRef {
|
||||
path := C.CString(gpath)
|
||||
|
@ -28,6 +28,9 @@ func arobotgo() {
|
||||
bit_map := robotgo.CaptureScreen(10, 20, 30, 40)
|
||||
Println("...", bit_map)
|
||||
|
||||
fx, fy := robotgo.FindBitmap(bit_map)
|
||||
Println("FindBitmap------", fx, fy)
|
||||
|
||||
robotgo.SaveBitmap(bit_map, "test.png", 1)
|
||||
|
||||
// robotgo.MouseClick()
|
||||
|
Loading…
Reference in New Issue
Block a user