Blender  V3.3
Macros | Functions
gpencil_trace.h File Reference
#include "potracelib.h"

Go to the source code of this file.

Macros

#define BM_WORDSIZE   ((int)sizeof(potrace_word))
 
#define BM_WORDBITS   (8 * BM_WORDSIZE)
 
#define BM_HIBIT   (((potrace_word)1) << (BM_WORDBITS - 1))
 
#define BM_ALLBITS   (~(potrace_word)0)
 
#define bm_scanline(bm, y)   ((bm)->map + (y) * (bm)->dy)
 
#define bm_index(bm, x, y)   (&bm_scanline(bm, y)[(x) / BM_WORDBITS])
 
#define bm_mask(x)   (BM_HIBIT >> ((x) & (BM_WORDBITS - 1)))
 
#define bm_range(x, a)   ((int)(x) >= 0 && (int)(x) < (a))
 
#define bm_safe(bm, x, y)   (bm_range(x, (bm)->w) && bm_range(y, (bm)->h))
 
#define BM_UGET(bm, x, y)   ((*bm_index(bm, x, y) & bm_mask(x)) != 0)
 
#define BM_USET(bm, x, y)   (*bm_index(bm, x, y) |= bm_mask(x))
 
#define BM_UCLR(bm, x, y)   (*bm_index(bm, x, y) &= ~bm_mask(x))
 
#define BM_UINV(bm, x, y)   (*bm_index(bm, x, y) ^= bm_mask(x))
 
#define BM_UPUT(bm, x, y, b)   ((b) ? BM_USET(bm, x, y) : BM_UCLR(bm, x, y))
 
#define BM_GET(bm, x, y)   (bm_safe(bm, x, y) ? BM_UGET(bm, x, y) : 0)
 
#define BM_SET(bm, x, y)   (bm_safe(bm, x, y) ? BM_USET(bm, x, y) : 0)
 
#define BM_CLR(bm, x, y)   (bm_safe(bm, x, y) ? BM_UCLR(bm, x, y) : 0)
 
#define BM_INV(bm, x, y)   (bm_safe(bm, x, y) ? BM_UINV(bm, x, y) : 0)
 
#define BM_PUT(bm, x, y, b)   (bm_safe(bm, x, y) ? BM_UPUT(bm, x, y, b) : 0)
 
#define GPENCIL_TRACE_MODE_SINGLE   0
 
#define GPENCIL_TRACE_MODE_SEQUENCE   1
 

Functions

void ED_gpencil_trace_bitmap_print (FILE *f, const potrace_bitmap_t *bm)
 
potrace_bitmap_t * ED_gpencil_trace_bitmap_new (int32_t w, int32_t h)
 
void ED_gpencil_trace_bitmap_free (const potrace_bitmap_t *bm)
 
void ED_gpencil_trace_bitmap_invert (const potrace_bitmap_t *bm)
 
void ED_gpencil_trace_image_to_bitmap (struct ImBuf *ibuf, const potrace_bitmap_t *bm, float threshold)
 
void ED_gpencil_trace_data_to_strokes (struct Main *bmain, potrace_state_t *st, struct Object *ob, struct bGPDframe *gpf, int32_t offset[2], float scale, float sample, int32_t resolution, int32_t thickness)
 

Macro Definition Documentation

◆ BM_ALLBITS

#define BM_ALLBITS   (~(potrace_word)0)

Definition at line 23 of file gpencil_trace.h.

◆ BM_CLR

#define BM_CLR (   bm,
  x,
  y 
)    (bm_safe(bm, x, y) ? BM_UCLR(bm, x, y) : 0)

Definition at line 38 of file gpencil_trace.h.

◆ BM_GET

#define BM_GET (   bm,
  x,
  y 
)    (bm_safe(bm, x, y) ? BM_UGET(bm, x, y) : 0)

Definition at line 36 of file gpencil_trace.h.

◆ BM_HIBIT

#define BM_HIBIT   (((potrace_word)1) << (BM_WORDBITS - 1))

Definition at line 22 of file gpencil_trace.h.

◆ bm_index

#define bm_index (   bm,
  x,
  y 
)    (&bm_scanline(bm, y)[(x) / BM_WORDBITS])

Definition at line 26 of file gpencil_trace.h.

◆ BM_INV

#define BM_INV (   bm,
  x,
  y 
)    (bm_safe(bm, x, y) ? BM_UINV(bm, x, y) : 0)

Definition at line 39 of file gpencil_trace.h.

◆ bm_mask

#define bm_mask (   x)    (BM_HIBIT >> ((x) & (BM_WORDBITS - 1)))

Definition at line 27 of file gpencil_trace.h.

◆ BM_PUT

#define BM_PUT (   bm,
  x,
  y,
 
)    (bm_safe(bm, x, y) ? BM_UPUT(bm, x, y, b) : 0)

Definition at line 40 of file gpencil_trace.h.

◆ bm_range

#define bm_range (   x,
 
)    ((int)(x) >= 0 && (int)(x) < (a))

Definition at line 28 of file gpencil_trace.h.

◆ bm_safe

#define bm_safe (   bm,
  x,
  y 
)    (bm_range(x, (bm)->w) && bm_range(y, (bm)->h))

Definition at line 29 of file gpencil_trace.h.

◆ bm_scanline

#define bm_scanline (   bm,
  y 
)    ((bm)->map + (y) * (bm)->dy)

Definition at line 25 of file gpencil_trace.h.

◆ BM_SET

#define BM_SET (   bm,
  x,
  y 
)    (bm_safe(bm, x, y) ? BM_USET(bm, x, y) : 0)

Definition at line 37 of file gpencil_trace.h.

◆ BM_UCLR

#define BM_UCLR (   bm,
  x,
  y 
)    (*bm_index(bm, x, y) &= ~bm_mask(x))

Definition at line 33 of file gpencil_trace.h.

◆ BM_UGET

#define BM_UGET (   bm,
  x,
  y 
)    ((*bm_index(bm, x, y) & bm_mask(x)) != 0)

Definition at line 31 of file gpencil_trace.h.

◆ BM_UINV

#define BM_UINV (   bm,
  x,
  y 
)    (*bm_index(bm, x, y) ^= bm_mask(x))

Definition at line 34 of file gpencil_trace.h.

◆ BM_UPUT

#define BM_UPUT (   bm,
  x,
  y,
 
)    ((b) ? BM_USET(bm, x, y) : BM_UCLR(bm, x, y))

Definition at line 35 of file gpencil_trace.h.

◆ BM_USET

#define BM_USET (   bm,
  x,
  y 
)    (*bm_index(bm, x, y) |= bm_mask(x))

Definition at line 32 of file gpencil_trace.h.

◆ BM_WORDBITS

#define BM_WORDBITS   (8 * BM_WORDSIZE)

Definition at line 21 of file gpencil_trace.h.

◆ BM_WORDSIZE

#define BM_WORDSIZE   ((int)sizeof(potrace_word))

Definition at line 20 of file gpencil_trace.h.

◆ GPENCIL_TRACE_MODE_SEQUENCE

#define GPENCIL_TRACE_MODE_SEQUENCE   1

Definition at line 44 of file gpencil_trace.h.

◆ GPENCIL_TRACE_MODE_SINGLE

#define GPENCIL_TRACE_MODE_SINGLE   0

Definition at line 43 of file gpencil_trace.h.

Function Documentation

◆ ED_gpencil_trace_bitmap_free()

void ED_gpencil_trace_bitmap_free ( const potrace_bitmap_t *  bm)

Free a trace bitmap

Parameters
bmTrace bitmap

Definition at line 80 of file gpencil_trace_utils.c.

References bm, free(), MEM_SAFE_FREE, and NULL.

Referenced by gpencil_trace_image().

◆ ED_gpencil_trace_bitmap_invert()

void ED_gpencil_trace_bitmap_invert ( const potrace_bitmap_t *  bm)

Invert the given bitmap (Black to White)

Parameters
bmTrace bitmap

Definition at line 88 of file gpencil_trace_utils.c.

References bm, BM_ALLBITS, bm_scanline, and y.

◆ ED_gpencil_trace_bitmap_new()

potrace_bitmap_t* ED_gpencil_trace_bitmap_new ( int32_t  w,
int32_t  h 
)

Return new un-initialized trace bitmap

Parameters
wWidth in pixels
hHeight in pixels
Returns
Trace bitmap

Definition at line 59 of file gpencil_trace_utils.c.

References bm, BM_WORDBITS, BM_WORDSIZE, free(), MEM_mallocN, NULL, and w().

Referenced by gpencil_trace_image().

◆ ED_gpencil_trace_bitmap_print()

void ED_gpencil_trace_bitmap_print ( FILE *  f,
const potrace_bitmap_t *  bm 
)

Print trace bitmap for debugging.

Parameters
fOutput handle. Use stderr for printing
bmTrace bitmap

Definition at line 33 of file gpencil_trace_utils.c.

References bm, BM_GET, sh, sw, x, and y.

◆ ED_gpencil_trace_data_to_strokes()

void ED_gpencil_trace_data_to_strokes ( struct Main bmain,
potrace_state_t *  st,
struct Object ob,
struct bGPDframe gpf,
int32_t  offset[2],
float  scale,
float  sample,
int32_t  resolution,
int32_t  thickness 
)

◆ ED_gpencil_trace_image_to_bitmap()

void ED_gpencil_trace_image_to_bitmap ( struct ImBuf ibuf,
const potrace_bitmap_t *  bm,
float  threshold 
)

Convert image to BW bitmap for tracing

Parameters
ibufImBuf of the image
bmTrace bitmap

Definition at line 130 of file gpencil_trace_utils.c.

References bm, BM_PUT, color, mul_v3_fl(), pixel_at_index(), usdtokens::rgba(), threshold, x, ImBuf::x, y, and ImBuf::y.

Referenced by gpencil_trace_image().