diff options
| author | yangwei <[email protected]> | 2024-08-06 20:37:59 +0800 |
|---|---|---|
| committer | luwenpeng <[email protected]> | 2024-08-12 15:45:50 +0800 |
| commit | 6786372449b70caaaf6824e1ed0e59800659b2d6 (patch) | |
| tree | 869aaa46825ce60d224338f8040f1a1b35f5df00 /deps | |
| parent | ee695957205fceb7990d123f6cccf7de3e58c12c (diff) | |
✨ feat(plugin manager integration): packet and session exdata&mq
Diffstat (limited to 'deps')
| -rw-r--r-- | deps/bitmap/bitmap.c | 17 | ||||
| -rw-r--r-- | deps/bitmap/bitmap.h | 6 |
2 files changed, 20 insertions, 3 deletions
diff --git a/deps/bitmap/bitmap.c b/deps/bitmap/bitmap.c index 59fb4b7..068bc3f 100644 --- a/deps/bitmap/bitmap.c +++ b/deps/bitmap/bitmap.c @@ -46,8 +46,21 @@ void bitmap_free(struct bitmap *bmp) { } } - - +int bitmap_is_all_zero(struct bitmap *bmp, int x, int y, int length) { + if (x < 0 || y < 0 || x >= bmp->width || y >= bmp->height) { + return -1; // Return error code if coordinates are out of bounds + } + int idx = y * bmp->width + x; + if (idx + length > bmp->width * bmp->height) { + return -1; // Return error if range exceeds bitmap bounds + } + for (int i = 0; i < length; i++) { + if (bmp->data[(idx + i) / 8] & (1 << ((idx + i) % 8))) { + return 0; // Return 0 if any bit is not zero + } + } + return 1; // Return 1 if all bits are zero +} int test_bitmap() { struct bitmap *bmp = bitmap_new(10, 5, 1); // Create a 10x5 bitmap diff --git a/deps/bitmap/bitmap.h b/deps/bitmap/bitmap.h index 210ea35..5fbf469 100644 --- a/deps/bitmap/bitmap.h +++ b/deps/bitmap/bitmap.h @@ -1,5 +1,9 @@ +#pragma once + struct bitmap; struct bitmap * bitmap_new(int width, int height, int value); int bitmap_set(struct bitmap *bmp, int x, int y, int value); int bitmap_get(struct bitmap *bmp, int x, int y); -void bitmap_free(struct bitmap *bmp);
\ No newline at end of file +void bitmap_free(struct bitmap *bmp); + +int bitmap_is_all_zero(struct bitmap *bmp, int x, int y, int length); |
