42 printf(
"ERROR: error_no=%04X, detail_no=%u\n", (HPDF_UINT)error_no, (HPDF_UINT)detail_no);
46 GpencilExporterPDF::GpencilExporterPDF(
const char *filepath,
const GpencilIOParams *iparams)
60 return create_document();
70 export_gpencil_layers();
85 std::wstring wstr(filepath_cstr_16);
86 res = HPDF_SaveToFile(pdf_, wstr.c_str());
93 return (res == 0) ? true :
false;
96 bool GpencilExporterPDF::create_document()
100 std::cout <<
"error: cannot create PdfDoc object\n";
106 bool GpencilExporterPDF::add_page()
109 page_ = HPDF_AddPage(pdf_);
111 std::cout <<
"error: cannot create PdfPage\n";
121 void GpencilExporterPDF::export_gpencil_layers()
142 if ((gpf ==
nullptr) || (gpf->
strokes.
first ==
nullptr)) {
147 if (gps->totpoints < 2) {
155 const float fill_opacity =
fill_color_[3] * gpl->opacity;
170 if ((!is_stroke) && (!is_fill)) {
178 gps_duplicate->
thickness += gpl->line_change;
185 export_stroke_to_polyline(gpl, gps_duplicate, is_stroke,
true,
false);
191 export_stroke_to_polyline(gpl, gps_duplicate, is_stroke,
false,
true);
202 export_stroke_to_polyline(gpl, gps_perimeter, is_stroke,
false,
false);
213 void GpencilExporterPDF::export_stroke_to_polyline(
bGPDlayer *gpl,
215 const bool is_stroke,
225 gps_temp->
points = MEM_new<bGPDspoint>(
"gp_stroke_points");
235 color_set(gpl, do_fill);
237 if (is_stroke && !do_fill) {
238 HPDF_Page_SetLineJoin(page_, HPDF_ROUND_JOIN);
239 HPDF_Page_SetLineWidth(page_,
MAX2((radius * 2.0f) - gpl->
line_change, 1.0f));
243 for (
const int i : IndexRange(gps->
totpoints)) {
247 HPDF_Page_MoveTo(page_, screen_co.
x, screen_co.
y);
250 HPDF_Page_LineTo(page_, screen_co.
x, screen_co.
y);
255 HPDF_Page_ClosePath(page_);
259 HPDF_Page_Fill(page_);
262 HPDF_Page_Stroke(page_);
265 HPDF_Page_GRestore(page_);
268 void GpencilExporterPDF::color_set(
bGPDlayer *gpl,
const bool do_fill)
272 const bool need_state = (do_fill && fill_opacity < 1.0f) || (stroke_opacity < 1.0f);
274 HPDF_Page_GSave(page_);
275 HPDF_ExtGState gstate = (need_state) ? HPDF_CreateExtGState(pdf_) :
nullptr;
282 HPDF_Page_SetRGBFill(page_,
col[0],
col[1],
col[2]);
284 HPDF_ExtGState_SetAlphaFill(gstate,
clamp_f(fill_opacity, 0.0f, 1.0f));
292 HPDF_Page_SetRGBFill(page_,
col[0],
col[1],
col[2]);
293 HPDF_Page_SetRGBStroke(page_,
col[0],
col[1],
col[2]);
295 HPDF_ExtGState_SetAlphaFill(gstate,
clamp_f(stroke_opacity, 0.0f, 1.0f));
296 HPDF_ExtGState_SetAlphaStroke(gstate,
clamp_f(stroke_opacity, 0.0f, 1.0f));
300 HPDF_Page_SetExtGState(page_, gstate);
struct bGPDstroke * BKE_gpencil_stroke_duplicate(struct bGPDstroke *gps_src, bool dup_points, bool dup_curve)
#define GPENCIL_ALPHA_OPACITY_THRESH
void BKE_gpencil_free_stroke(struct bGPDstroke *gps)
float BKE_gpencil_stroke_average_pressure_get(struct bGPDstroke *gps)
struct bGPDstroke * BKE_gpencil_stroke_perimeter_from_view(struct RegionView3D *rv3d, struct bGPdata *gpd, const struct bGPDlayer *gpl, struct bGPDstroke *gps, int subdivisions, const float diff_mat[4][4])
bool BKE_gpencil_stroke_sample(struct bGPdata *gpd, struct bGPDstroke *gps, const float dist, const bool select, const float sharp_threshold)
General operations, lookup, etc. for materials.
struct MaterialGPencilStyle * BKE_gpencil_material_settings(struct Object *ob, short act)
#define LISTBASE_FOREACH(type, var, list)
MINLINE float clamp_f(float value, float min, float max)
MINLINE void linearrgb_to_srgb_v3_v3(float srgb[3], const float linear[3])
float mat4_to_scale(const float M[4][4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
static struct error_handler_data error_handler
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
#define CLAMP3(vec, b, c)
struct ID * DEG_get_evaluated_id(const struct Depsgraph *depsgraph, struct ID *id)
@ GP_MATERIAL_STROKE_SHOW
Object is a sort of wrapper for general info.
void filepath_set(const char *filepath)
float stroke_point_radius_get(struct bGPDlayer *gpl, struct bGPDstroke *gps)
blender::Vector< ObjectZ > ob_list_
struct Depsgraph * depsgraph_
void create_object_list()
struct RegionView3D * rv3d_
void prepare_stroke_export_colors(struct Object *ob, struct bGPDstroke *gps)
float2 gpencil_3D_point_to_2D(const float3 co)
float stroke_average_opacity_get()
void prepare_layer_export_matrix(struct Object *ob, struct bGPDlayer *gpl)
@ GP_EXPORT_NORM_THICKNESS
bool ED_gpencil_stroke_material_visible(Object *ob, const bGPDstroke *gps)
vec_base< T, Size > normalize(const vec_base< T, Size > &v)
#define UTF16_ENCODE(in8str)
#define UTF16_UN_ENCODE(in8str)