diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-05-17 16:45:08 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-05-20 14:31:08 +0200 |
commit | a4b7981d56e3cb22e2a1c18e40906e88fc331da5 (patch) | |
tree | 18d28476fd50f2740cd1d2945f81467836f46079 /source/svg/svg-doc.c | |
parent | c04aa7a89f5bbb5a4657c92a7748c4f41984c4e3 (diff) | |
download | mupdf-a4b7981d56e3cb22e2a1c18e40906e88fc331da5.tar.xz |
html: Add SVG image support.
Diffstat (limited to 'source/svg/svg-doc.c')
-rw-r--r-- | source/svg/svg-doc.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/source/svg/svg-doc.c b/source/svg/svg-doc.c index 9b7aa670..25f00e62 100644 --- a/source/svg/svg-doc.c +++ b/source/svg/svg-doc.c @@ -150,14 +150,18 @@ svg_recognize(fz_context *ctx, const char *magic) } fz_display_list * -fz_new_display_list_from_svg(fz_context *ctx, fz_buffer *buf) +fz_new_display_list_from_svg(fz_context *ctx, fz_buffer *buf, float *w, float *h) { fz_document *doc; fz_display_list *list; doc = svg_open_document_with_buffer(ctx, buf); fz_try(ctx) + { list = fz_new_display_list_from_page_number(ctx, doc, 0); + *w = ((svg_document*)doc)->width; + *h = ((svg_document*)doc)->height; + } fz_always(ctx) fz_drop_document(ctx, doc); fz_catch(ctx) @@ -166,6 +170,23 @@ fz_new_display_list_from_svg(fz_context *ctx, fz_buffer *buf) return list; } +fz_image * +fz_new_image_from_svg(fz_context *ctx, fz_buffer *buf) +{ + fz_display_list *list; + fz_image *image; + float w, h; + + list = fz_new_display_list_from_svg(ctx, buf, &w, &h); + fz_try(ctx) + image = fz_new_image_from_display_list(ctx, w, h, list); + fz_always(ctx) + fz_drop_display_list(ctx, list); + fz_catch(ctx) + fz_rethrow(ctx); + return image; +} + fz_document_handler svg_document_handler = { &svg_recognize, |