diff options
-rw-r--r-- | include/mupdf/pdf/annot.h | 2 | ||||
-rw-r--r-- | source/pdf/pdf-annot-edit.c | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/include/mupdf/pdf/annot.h b/include/mupdf/pdf/annot.h index 2dd47f27..c29b6c31 100644 --- a/include/mupdf/pdf/annot.h +++ b/include/mupdf/pdf/annot.h @@ -155,6 +155,7 @@ int pdf_annot_has_author(fz_context *ctx, pdf_annot *annot); int pdf_annot_flags(fz_context *ctx, pdf_annot *annot); void pdf_annot_rect(fz_context *ctx, pdf_annot *annot, fz_rect *rect); float pdf_annot_border(fz_context *ctx, pdf_annot *annot); +float pdf_annot_opacity(fz_context *ctx, pdf_annot *annot); void pdf_annot_color(fz_context *ctx, pdf_annot *annot, int *n, float color[4]); void pdf_annot_interior_color(fz_context *ctx, pdf_annot *annot, int *n, float color[4]); @@ -168,6 +169,7 @@ fz_point pdf_annot_ink_list_stroke_vertex(fz_context *ctx, pdf_annot *annot, int void pdf_set_annot_flags(fz_context *ctx, pdf_annot *annot, int flags); void pdf_set_annot_rect(fz_context *ctx, pdf_annot *annot, const fz_rect *rect); void pdf_set_annot_border(fz_context *ctx, pdf_annot *annot, float width); +void pdf_set_annot_opacity(fz_context *ctx, pdf_annot *annot, float opacity); void pdf_set_annot_color(fz_context *ctx, pdf_annot *annot, int n, const float color[4]); void pdf_set_annot_interior_color(fz_context *ctx, pdf_annot *annot, int n, const float color[4]); diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c index 1d042f1f..799fb9b7 100644 --- a/source/pdf/pdf-annot-edit.c +++ b/source/pdf/pdf-annot-edit.c @@ -479,6 +479,23 @@ pdf_set_annot_border(fz_context *ctx, pdf_annot *annot, float w) pdf_dirty_annot(ctx, annot); } +float pdf_annot_opacity(fz_context *ctx, pdf_annot *annot) +{ + pdf_obj *ca = pdf_dict_get(ctx, annot->obj, PDF_NAME_CA); + if (pdf_is_number(ctx, ca)) + return pdf_to_real(ctx, ca); + return 1; +} + +void pdf_set_annot_opacity(fz_context *ctx, pdf_annot *annot, float opacity) +{ + if (opacity != 1) + pdf_dict_put_real(ctx, annot->obj, PDF_NAME_CA, opacity); + else + pdf_dict_del(ctx, annot->obj, PDF_NAME_CA); + pdf_dirty_annot(ctx, annot); +} + static void pdf_annot_color_imp(fz_context *ctx, pdf_annot *annot, pdf_obj *key, int *n, float color[4], pdf_obj **allowed) { pdf_obj *arr; |