From 3ab4938180ee24769b081badfe6c2fe91c924b3f Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 16 Jun 2016 11:22:57 +0200 Subject: Add fz_draw_options struct for use with draw device. --- source/fitz/output-cbz.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) (limited to 'source/fitz/output-cbz.c') diff --git a/source/fitz/output-cbz.c b/source/fitz/output-cbz.c index 4c6d0ca0..ebfded4c 100644 --- a/source/fitz/output-cbz.c +++ b/source/fitz/output-cbz.c @@ -8,32 +8,18 @@ struct fz_cbz_writer_s { fz_document_writer super; fz_zip_writer *zip; - float resolution; + fz_draw_options options; fz_pixmap *pixmap; int count; }; -const char *fz_cbz_write_options_usage = - "CBZ output options:\n" - "\tresolution=N: resolution of rendered pages in pixels per inch (default 96)\n" - ; +const char *fz_cbz_write_options_usage = ""; static fz_device * -cbz_begin_page(fz_context *ctx, fz_document_writer *wri_, const fz_rect *mediabox, fz_matrix *ctm) +cbz_begin_page(fz_context *ctx, fz_document_writer *wri_, const fz_rect *mediabox, fz_matrix *transform) { fz_cbz_writer *wri = (fz_cbz_writer*)wri_; - fz_rect bbox; - fz_irect ibbox; - - fz_scale(ctm, wri->resolution / 72, wri->resolution / 72); - bbox = *mediabox; - fz_transform_rect(&bbox, ctm); - fz_round_rect(&ibbox, &bbox); - - wri->pixmap = fz_new_pixmap_with_bbox(ctx, fz_device_rgb(ctx), &ibbox, 1); - fz_clear_pixmap_with_value(ctx, wri->pixmap, 0xFF); - - return fz_new_draw_device(ctx, wri->pixmap); + return fz_new_draw_device_with_options(ctx, &wri->options, mediabox, transform, &wri->pixmap); } static void @@ -57,6 +43,8 @@ cbz_end_page(fz_context *ctx, fz_document_writer *wri_, fz_device *dev) fz_drop_pixmap(ctx, wri->pixmap); wri->pixmap = NULL; + + fz_drop_device(ctx, dev); } static void @@ -74,7 +62,6 @@ cbz_close(fz_context *ctx, fz_document_writer *wri_) fz_document_writer * fz_new_cbz_writer(fz_context *ctx, const char *path, const char *options) { - const char *val; fz_cbz_writer *wri; wri = fz_malloc_struct(ctx, fz_cbz_writer); @@ -83,18 +70,15 @@ fz_new_cbz_writer(fz_context *ctx, const char *path, const char *options) wri->super.close = cbz_close; fz_try(ctx) + { + fz_parse_draw_options(ctx, &wri->options, options); wri->zip = fz_new_zip_writer(ctx, path); + } fz_catch(ctx) { fz_free(ctx, wri); fz_rethrow(ctx); } - if (fz_has_option(ctx, options, "resolution", &val)) - wri->resolution = fz_atof(val); - - if (wri->resolution <= 0) - wri->resolution = 96; - return (fz_document_writer*)wri; } -- cgit v1.2.3