fz_document_writer * fz_new_pwg_writer(fz_context *ctx, const char *path, const char *options) { fz_pwg_writer *wri = fz_new_derived_document_writer(ctx, fz_pwg_writer, pwg_begin_page, pwg_end_page, pwg_close_writer, pwg_drop_writer); const char *val; fz_try(ctx) { fz_parse_draw_options(ctx, &wri->draw, options); fz_parse_pwg_options(ctx, &wri->pwg, options); if (fz_has_option(ctx, options, "colorspace", &val)) if (fz_option_eq(val, "mono")) wri->mono = 1; wri->out = fz_new_output_with_path(ctx, path ? path : "out.pwg", 0); fz_write_pwg_file_header(ctx, wri->out); } fz_catch(ctx) { fz_drop_output(ctx, wri->out); fz_free(ctx, wri); fz_rethrow(ctx); } return (fz_document_writer*)wri; }
fz_document_writer * fz_new_pixmap_writer(fz_context *ctx, const char *path, const char *options, const char *default_path, int n, void (*save)(fz_context *ctx, fz_pixmap *pix, const char *filename)) { fz_pixmap_writer *wri = fz_new_derived_document_writer(ctx, fz_pixmap_writer, pixmap_begin_page, pixmap_end_page, NULL, pixmap_drop_writer); fz_try(ctx) { fz_parse_draw_options(ctx, &wri->options, options); wri->path = fz_strdup(ctx, path ? path : default_path); wri->save = save; switch (n) { case 1: wri->options.colorspace = fz_device_gray(ctx); break; case 3: wri->options.colorspace = fz_device_rgb(ctx); break; case 4: wri->options.colorspace = fz_device_cmyk(ctx); break; } } fz_catch(ctx) { fz_free(ctx, wri); fz_rethrow(ctx); } return (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_new_derived_document_writer(ctx, fz_cbz_writer, cbz_begin_page, cbz_end_page, cbz_close_writer, cbz_drop_writer); fz_try(ctx) { fz_parse_draw_options(ctx, &wri->options, options); wri->zip = fz_new_zip_writer(ctx, path ? path : "out.cbz"); } fz_catch(ctx) { fz_free(ctx, wri); fz_rethrow(ctx); } return (fz_document_writer*)wri; }
fz_document_writer * fz_new_cbz_writer(fz_context *ctx, const char *path, const char *options) { 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.close_writer = cbz_close_writer; wri->super.drop_writer = cbz_drop_writer; fz_try(ctx) { fz_parse_draw_options(ctx, &wri->options, options); wri->zip = fz_new_zip_writer(ctx, path ? path : "out.cbz"); } fz_catch(ctx) { fz_free(ctx, wri); fz_rethrow(ctx); } return (fz_document_writer*)wri; }