Blender  V3.3
Macros | Functions
gpencil_trace_utils.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_geom.h"
#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "DNA_gpencil_types.h"
#include "DNA_image_types.h"
#include "DNA_material_types.h"
#include "DNA_object_types.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "gpencil_trace.h"

Go to the source code of this file.

Macros

#define MAX_LENGTH   100.0f
 

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)
 
static void pixel_at_index (const ImBuf *ibuf, const int32_t idx, float r_col[4])
 
void ED_gpencil_trace_image_to_bitmap (ImBuf *ibuf, const potrace_bitmap_t *bm, const float threshold)
 
static void add_point (bGPDstroke *gps, float scale, const int32_t offset[2], float x, float y)
 
static void add_bezier (bGPDstroke *gps, float scale, int32_t offset[2], int32_t resolution, float bcp1[2], float bcp2[2], float bcp3[2], float bcp4[2], const bool skip)
 
void ED_gpencil_trace_data_to_strokes (Main *bmain, potrace_state_t *st, Object *ob, bGPDframe *gpf, int32_t offset[2], const float scale, const float sample, const int32_t resolution, const int32_t thickness)
 

Macro Definition Documentation

◆ MAX_LENGTH

#define MAX_LENGTH   100.0f

Function Documentation

◆ add_bezier()

static void add_bezier ( bGPDstroke gps,
float  scale,
int32_t  offset[2],
int32_t  resolution,
float  bcp1[2],
float  bcp2[2],
float  bcp3[2],
float  bcp4[2],
const bool  skip 
)
static

◆ add_point()

static void add_point ( bGPDstroke gps,
float  scale,
const int32_t  offset[2],
float  x,
float  y 
)
static

◆ 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().

◆ pixel_at_index()

static void pixel_at_index ( const ImBuf ibuf,
const int32_t  idx,
float  r_col[4] 
)
static

Return pixel data (rgba) at index

Parameters
ibufImBuf of the image
idxIndex of the pixel
Returns
RGBA value

Definition at line 113 of file gpencil_trace_utils.c.

References BLI_assert, copy_v4_v4(), float(), ImBuf::rect, ImBuf::rect_float, ImBuf::x, and ImBuf::y.

Referenced by ED_gpencil_trace_image_to_bitmap().