Lines Matching defs:bm
32 #define bm_scanline(bm, y) ((bm)->map + (ptrdiff_t)(y)*(ptrdiff_t)(bm)->dy)
33 #define bm_index(bm, x, y) (&bm_scanline(bm, y)[(x)/BM_WORDBITS])
36 #define bm_safe(bm, x, y) (bm_range(x, (bm)->w) && bm_range(y, (bm)->h))
37 #define BM_UGET(bm, x, y) ((*bm_index(bm, x, y) & bm_mask(x)) != 0)
38 #define BM_USET(bm, x, y) (*bm_index(bm, x, y) |= bm_mask(x))
39 #define BM_UCLR(bm, x, y) (*bm_index(bm, x, y) &= ~bm_mask(x))
40 #define BM_UINV(bm, x, y) (*bm_index(bm, x, y) ^= bm_mask(x))
41 #define BM_UPUT(bm, x, y, b) ((b) ? BM_USET(bm, x, y) : BM_UCLR(bm, x, y))
42 #define BM_GET(bm, x, y) (bm_safe(bm, x, y) ? BM_UGET(bm, x, y) : 0)
43 #define BM_SET(bm, x, y) (bm_safe(bm, x, y) ? BM_USET(bm, x, y) : 0)
44 #define BM_CLR(bm, x, y) (bm_safe(bm, x, y) ? BM_UCLR(bm, x, y) : 0)
45 #define BM_INV(bm, x, y) (bm_safe(bm, x, y) ? BM_UINV(bm, x, y) : 0)
46 #define BM_PUT(bm, x, y, b) (bm_safe(bm, x, y) ? BM_UPUT(bm, x, y, b) : 0)
49 static inline void bm_free(potrace_bitmap_t *bm) {
50 if (bm) {
51 free(bm->map);
53 free(bm);
59 potrace_bitmap_t *bm;
69 bm = (potrace_bitmap_t *) malloc(sizeof(potrace_bitmap_t));
70 if (!bm) {
73 bm->w = w;
74 bm->h = h;
75 bm->dy = dy;
76 bm->map = (potrace_word *) malloc(size);
77 if (!bm->map) {
78 free(bm);
81 return bm;
85 static inline void bm_clear(potrace_bitmap_t *bm, int c) {
88 ptrdiff_t size = (ptrdiff_t)bm->dy * (ptrdiff_t)bm->h * (ptrdiff_t)BM_WORDSIZE;
89 memset(bm->map, c ? -1 : 0, size);
93 static inline potrace_bitmap_t *bm_dup(const potrace_bitmap_t *bm) {
94 potrace_bitmap_t *bm1 = bm_new(bm->w, bm->h);
95 ptrdiff_t size = (ptrdiff_t)bm->dy * (ptrdiff_t)bm->h * (ptrdiff_t)BM_WORDSIZE;
99 memcpy(bm1->map, bm->map, size);
104 static inline void bm_invert(potrace_bitmap_t *bm) {
106 ptrdiff_t size = (ptrdiff_t)bm->dy * (ptrdiff_t)bm->h;
109 bm->map[i] ^= BM_ALLBITS;