Blender  V2.93
gpencil_trace.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2020 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #pragma once
25 
26 /* internal exports only */
27 struct FILE;
28 struct ImBuf;
29 struct Main;
30 struct Object;
31 struct bGPDframe;
32 
33 #include "potracelib.h"
34 
35 /* Potrace macros for writing individual bitmap pixels. */
36 #define BM_WORDSIZE ((int)sizeof(potrace_word))
37 #define BM_WORDBITS (8 * BM_WORDSIZE)
38 #define BM_HIBIT (((potrace_word)1) << (BM_WORDBITS - 1))
39 #define BM_ALLBITS (~(potrace_word)0)
40 
41 #define bm_scanline(bm, y) ((bm)->map + (y) * (bm)->dy)
42 #define bm_index(bm, x, y) (&bm_scanline(bm, y)[(x) / BM_WORDBITS])
43 #define bm_mask(x) (BM_HIBIT >> ((x) & (BM_WORDBITS - 1)))
44 #define bm_range(x, a) ((int)(x) >= 0 && (int)(x) < (a))
45 #define bm_safe(bm, x, y) (bm_range(x, (bm)->w) && bm_range(y, (bm)->h))
46 
47 #define BM_UGET(bm, x, y) ((*bm_index(bm, x, y) & bm_mask(x)) != 0)
48 #define BM_USET(bm, x, y) (*bm_index(bm, x, y) |= bm_mask(x))
49 #define BM_UCLR(bm, x, y) (*bm_index(bm, x, y) &= ~bm_mask(x))
50 #define BM_UINV(bm, x, y) (*bm_index(bm, x, y) ^= bm_mask(x))
51 #define BM_UPUT(bm, x, y, b) ((b) ? BM_USET(bm, x, y) : BM_UCLR(bm, x, y))
52 #define BM_GET(bm, x, y) (bm_safe(bm, x, y) ? BM_UGET(bm, x, y) : 0)
53 #define BM_SET(bm, x, y) (bm_safe(bm, x, y) ? BM_USET(bm, x, y) : 0)
54 #define BM_CLR(bm, x, y) (bm_safe(bm, x, y) ? BM_UCLR(bm, x, y) : 0)
55 #define BM_INV(bm, x, y) (bm_safe(bm, x, y) ? BM_UINV(bm, x, y) : 0)
56 #define BM_PUT(bm, x, y, b) (bm_safe(bm, x, y) ? BM_UPUT(bm, x, y, b) : 0)
57 
58 /* Trace modes */
59 #define GPENCIL_TRACE_MODE_SINGLE 0
60 #define GPENCIL_TRACE_MODE_SEQUENCE 1
61 
62 void ED_gpencil_trace_bitmap_print(FILE *f, const potrace_bitmap_t *bm);
63 
64 potrace_bitmap_t *ED_gpencil_trace_bitmap_new(int32_t w, int32_t h);
65 void ED_gpencil_trace_bitmap_free(const potrace_bitmap_t *bm);
66 void ED_gpencil_trace_bitmap_invert(const potrace_bitmap_t *bm);
67 
68 void ED_gpencil_trace_image_to_bitmap(struct ImBuf *ibuf,
69  const potrace_bitmap_t *bm,
70  const float threshold);
71 
72 void ED_gpencil_trace_data_to_strokes(struct Main *bmain,
73  potrace_state_t *st,
74  struct Object *ob,
75  struct bGPDframe *gpf,
76  int32_t offset[2],
77  const float scale,
78  const float sample,
79  const int32_t resolution,
80  const int32_t thickness);
ATTR_WARN_UNUSED_RESULT BMesh * bm
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
void ED_gpencil_trace_bitmap_print(FILE *f, const potrace_bitmap_t *bm)
void ED_gpencil_trace_bitmap_free(const potrace_bitmap_t *bm)
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)
void ED_gpencil_trace_bitmap_invert(const potrace_bitmap_t *bm)
potrace_bitmap_t * ED_gpencil_trace_bitmap_new(int32_t w, int32_t h)
static void sample(SocketReader *reader, int x, int y, float color[4])
signed int int32_t
Definition: stdint.h:80
Definition: BKE_main.h:116