summaryrefslogtreecommitdiff
path: root/source/fitz/output-cbz.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-05-04 18:00:37 +0200
committerTor Andersson <tor.andersson@artifex.com>2016-05-13 11:42:00 +0200
commit9dda5aa73d6dcb72c9f10b87564afe7491575faf (patch)
tree31c3e2b2fb16431ad7236f7a44e206a3a391061b /source/fitz/output-cbz.c
parent74d75a7a6f3ea4bef5b4489c65e8a876ae480c76 (diff)
downloadmupdf-9dda5aa73d6dcb72c9f10b87564afe7491575faf.tar.xz
Add long output option parsing.
Use comma-separated list of flags and key/value pairs, for example: "linearize,resolution=72,colorspace=gray"
Diffstat (limited to 'source/fitz/output-cbz.c')
-rw-r--r--source/fitz/output-cbz.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/source/fitz/output-cbz.c b/source/fitz/output-cbz.c
index df5c0640..d6f1e07c 100644
--- a/source/fitz/output-cbz.c
+++ b/source/fitz/output-cbz.c
@@ -8,11 +8,16 @@ struct fz_cbz_writer_s
{
fz_document_writer super;
fz_zip_writer *zip;
- int resolution;
+ float resolution;
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"
+ ;
+
static fz_device *
cbz_begin_page(fz_context *ctx, fz_document_writer *wri_, const fz_rect *mediabox, fz_matrix *ctm)
{
@@ -69,8 +74,10 @@ cbz_drop_imp(fz_context *ctx, fz_document_writer *wri_)
fz_document_writer *
fz_new_cbz_writer(fz_context *ctx, const char *path, const char *options)
{
- fz_cbz_writer *wri = fz_malloc_struct(ctx, fz_cbz_writer);
+ const char *val;
+ fz_cbz_writer *wri;
+ wri = fz_malloc_struct(ctx, fz_cbz_writer);
wri->super.begin_page = cbz_begin_page;
wri->super.end_page = cbz_end_page;
wri->super.drop_imp = cbz_drop_imp;
@@ -83,11 +90,10 @@ fz_new_cbz_writer(fz_context *ctx, const char *path, const char *options)
fz_rethrow(ctx);
}
- // TODO: getopt-like comma separated list of options
- if (options)
- wri->resolution = atoi(options);
+ if (fz_has_option(ctx, options, "resolution", &val))
+ wri->resolution = fz_atof(val);
- if (wri->resolution == 0)
+ if (wri->resolution <= 0)
wri->resolution = 96;
return (fz_document_writer*)wri;