102 potrace_bitmap_t *
bm =
NULL;
103 potrace_param_t *param =
NULL;
104 potrace_state_t *st =
NULL;
113 param = potrace_param_default();
124 st = potrace_trace(param,
bm);
125 if (!st || st->status != POTRACE_STATUS_OK) {
128 potrace_state_free(st);
130 potrace_param_free(param);
138 offset[0] = ibuf->
x / 2;
139 offset[1] = ibuf->
y / 2;
145 float scale_potrace = trace_job->
scale * (640.0f / (
float)ibuf->
x) *
146 ((
float)ibuf->
x / (
float)ibuf->
y);
147 if (ibuf->
x > ibuf->
y) {
148 scale_potrace *= (
float)ibuf->
y / (
float)ibuf->
x;
162 potrace_state_free(st);
163 potrace_param_free(param);
214 static void trace_start_job(
void *customdata,
short *stop,
short *do_update,
float *progress)
218 trace_job->
stop = stop;
350 short stop = 0, do_update =
true;
384 {POTRACE_TURNPOLICY_BLACK,
388 "Prefers to connect black (foreground) components"},
389 {POTRACE_TURNPOLICY_WHITE,
393 "Prefers to connect white (background) components"},
394 {POTRACE_TURNPOLICY_LEFT,
"LEFT", 0,
"Left",
"Always take a left turn"},
395 {POTRACE_TURNPOLICY_RIGHT,
"RIGHT", 0,
"Right",
"Always take a right turn"},
396 {POTRACE_TURNPOLICY_MINORITY,
400 "Prefers to connect the color (black or white) that occurs least frequently in the local "
401 "neighborhood of the current position"},
402 {POTRACE_TURNPOLICY_MAJORITY,
406 "Prefers to connect the color (black or white) that occurs most frequently in the local "
407 "neighborhood of the current position"},
408 {POTRACE_TURNPOLICY_RANDOM,
"RANDOM", 0,
"Random",
"Choose pseudo-randomly"},
425 ot->
name =
"Trace Image to Grease Pencil";
426 ot->
idname =
"GPENCIL_OT_trace_image";
427 ot->
description =
"Extract Grease Pencil strokes from image";
443 "Target grease pencil");
448 ot->
srna,
"resolution", 5, 1, 20,
"Resolution",
"Resolution of the generated curves", 1, 20);
456 "Scale of the final stroke",
465 "Distance to sample points, zero to disable",
474 "Determine the lightness threshold above which strokes are generated",
480 POTRACE_TURNPOLICY_MINORITY,
482 "Determines how to resolve ambiguities during decomposition of bitmaps into paths");
488 "Determines if trace simple image or full sequence");
492 "Start At Current Frame",
493 "Trace Image starting in current image frame");
typedef float(TangentPoint)[2]
struct Scene * CTX_data_scene(const bContext *C)
struct Base * CTX_data_active_base(const bContext *C)
struct wmWindowManager * CTX_wm_manager(const bContext *C)
struct ViewLayer * CTX_data_view_layer(const bContext *C)
struct Object * CTX_data_active_object(const bContext *C)
struct View3D * CTX_wm_view3d(const bContext *C)
void CTX_wm_operator_poll_msg_set(struct bContext *C, const char *msg)
struct Main * CTX_data_main(const bContext *C)
struct wmWindow * CTX_wm_window(const bContext *C)
struct bGPDlayer * BKE_gpencil_layer_active_get(struct bGPdata *gpd)
struct bGPDframe * BKE_gpencil_layer_frame_get(struct bGPDlayer *gpl, int cframe, eGP_GetFrame_Mode addnew)
struct bGPDlayer * BKE_gpencil_layer_addnew(struct bGPdata *gpd, const char *name, bool setactive)
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
struct Object * BKE_view_layer_non_active_selected_object(struct ViewLayer *view_layer, const struct View3D *v3d)
void BKE_id_delete(struct Main *bmain, void *idv) ATTR_NONNULL()
General operations, lookup, etc. for blender objects.
bool BKE_object_obdata_is_libdata(const struct Object *ob)
void BKE_report(ReportList *reports, ReportType type, const char *message)
MINLINE int max_ii(int a, int b)
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
@ ID_RECALC_COPY_ON_WRITE
void ED_object_base_activate(struct bContext *C, struct Base *base)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
@ WM_JOB_TYPE_TRACE_IMAGE
ATTR_WARN_UNUSED_RESULT BMesh * bm
#define GPENCIL_TRACE_MODE_SINGLE
void ED_gpencil_trace_bitmap_free(const potrace_bitmap_t *bm)
#define GPENCIL_TRACE_MODE_SEQUENCE
void ED_gpencil_trace_data_to_strokes(struct Main *bmain, potrace_state_t *st, struct Object *ob, struct bGPDframe *gpf, int32_t offset[2], const float scale, const float sample, const int32_t resolution, const int32_t thickness)
void ED_gpencil_trace_image_to_bitmap(struct ImBuf *ibuf, const potrace_bitmap_t *bm, const float threshold)
potrace_bitmap_t * ED_gpencil_trace_bitmap_new(int32_t w, int32_t h)
static bool gpencil_trace_image_poll(bContext *C)
static bool gpencil_trace_image(TraceJob *trace_job, ImBuf *ibuf, bGPDframe *gpf)
static void trace_free_job(void *customdata)
static int gpencil_trace_image_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static void trace_start_job(void *customdata, short *stop, short *do_update, float *progress)
static int gpencil_trace_image_exec(bContext *C, wmOperator *op)
static void trace_end_job(void *customdata)
void GPENCIL_OT_trace_image(wmOperatorType *ot)
static void trace_initialize_job_data(TraceJob *trace_job)
Object * ED_gpencil_add_object(bContext *C, const float loc[3], ushort local_view_bits)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
int RNA_int_get(PointerRNA *ptr, const char *name)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_float_factor(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
unsigned short local_view_uuid
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
void WM_main_add_notifier(unsigned int type, void *reference)
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
wmJob * WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *name, int flag, int job_type)
void WM_jobs_callbacks(wmJob *wm_job, wm_jobs_start_callback startjob, void(*initjob)(void *), void(*update)(void *), void(*endjob)(void *))
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void(*free)(void *))
void WM_jobs_timer(wmJob *wm_job, double timestep, unsigned int note, unsigned int endnote)
int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width)