summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2017-03-24 15:27:17 -0400
committerRobin Watts <Robin.Watts@artifex.com>2017-03-24 15:29:21 -0400
commit11a544dbb2da9d5aeb608fb2e1afc97334e8dd1e (patch)
tree961ff34160d2f059454e8a89a10f32bd5e70778a
parentea75724276f1efabd5d78595af0d3d35f7cde659 (diff)
downloadmupdf-11a544dbb2da9d5aeb608fb2e1afc97334e8dd1e.tar.xz
Add fz_new_XXX_document_writer calls for pixmaps.
This enables people to access (say) a PNG writer without pulling in every single document writer at link time. (Of course, currently, without function level linking, even now we'll pull everything in, but we can improve this by splitting source files up).
-rw-r--r--include/mupdf/fitz/writer.h15
-rw-r--r--source/fitz/writer.c56
2 files changed, 63 insertions, 8 deletions
diff --git a/include/mupdf/fitz/writer.h b/include/mupdf/fitz/writer.h
index a7039097..2c2f967f 100644
--- a/include/mupdf/fitz/writer.h
+++ b/include/mupdf/fitz/writer.h
@@ -33,6 +33,21 @@ int fz_option_eq(const char *a, const char *b);
fz_document_writer *fz_new_document_writer(fz_context *ctx, const char *path, const char *format, const char *options);
+fz_document_writer *fz_new_png_pixmap_writer(fz_context *ctx, const char *path, const char *options);
+
+fz_document_writer *fz_new_tga_pixmap_writer(fz_context *ctx, const char *path, const char *options);
+
+fz_document_writer *fz_new_pam_pixmap_writer(fz_context *ctx, const char *path, const char *options);
+
+fz_document_writer *fz_new_pnm_pixmap_writer(fz_context *ctx, const char *path, const char *options);
+
+fz_document_writer *fz_new_pgm_pixmap_writer(fz_context *ctx, const char *path, const char *options);
+
+fz_document_writer *fz_new_ppm_pixmap_writer(fz_context *ctx, const char *path, const char *options);
+
+fz_document_writer *fz_new_pbm_pixmap_writer(fz_context *ctx, const char *path, const char *options);
+
+fz_document_writer *fz_new_pkm_pixmap_writer(fz_context *ctx, const char *path, const char *options);
fz_device *fz_begin_page(fz_context *ctx, fz_document_writer *wri, const fz_rect *mediabox);
void fz_end_page(fz_context *ctx, fz_document_writer *wri, fz_device *dev);
diff --git a/source/fitz/writer.c b/source/fitz/writer.c
index f9d5b8c1..67a1d5ef 100644
--- a/source/fitz/writer.c
+++ b/source/fitz/writer.c
@@ -61,6 +61,46 @@ fz_document_writer *fz_new_document_writer_of_size(fz_context *ctx, size_t size,
return wri;
}
+fz_document_writer *fz_new_png_pixmap_writer(fz_context *ctx, const char *path, const char *options)
+{
+ return fz_new_pixmap_writer(ctx, path, options, "out-%04.png", 0, fz_save_pixmap_as_png);
+}
+
+fz_document_writer *fz_new_tga_pixmap_writer(fz_context *ctx, const char *path, const char *options)
+{
+ return fz_new_pixmap_writer(ctx, path, options, "out-%04.tga", 0, fz_save_pixmap_as_tga);
+}
+
+fz_document_writer *fz_new_pam_pixmap_writer(fz_context *ctx, const char *path, const char *options)
+{
+ return fz_new_pixmap_writer(ctx, path, options, "out-%04.pam", 0, fz_save_pixmap_as_pam);
+}
+
+fz_document_writer *fz_new_pnm_pixmap_writer(fz_context *ctx, const char *path, const char *options)
+{
+ return fz_new_pixmap_writer(ctx, path, options, "out-%04.pnm", 0, fz_save_pixmap_as_pnm);
+}
+
+fz_document_writer *fz_new_pgm_pixmap_writer(fz_context *ctx, const char *path, const char *options)
+{
+ return fz_new_pixmap_writer(ctx, path, options, "out-%04.pgm", 1, fz_save_pixmap_as_pnm);
+}
+
+fz_document_writer *fz_new_ppm_pixmap_writer(fz_context *ctx, const char *path, const char *options)
+{
+ return fz_new_pixmap_writer(ctx, path, options, "out-%04.ppm", 3, fz_save_pixmap_as_pnm);
+}
+
+fz_document_writer *fz_new_pbm_pixmap_writer(fz_context *ctx, const char *path, const char *options)
+{
+ return fz_new_pixmap_writer(ctx, path, options, "out-%04.pbm", 1, fz_save_pixmap_as_pbm);
+}
+
+fz_document_writer *fz_new_pkm_pixmap_writer(fz_context *ctx, const char *path, const char *options)
+{
+ return fz_new_pixmap_writer(ctx, path, options, "out-%04.pkm", 4, fz_save_pixmap_as_pkm);
+}
+
fz_document_writer *
fz_new_document_writer(fz_context *ctx, const char *path, const char *format, const char *options)
{
@@ -82,21 +122,21 @@ fz_new_document_writer(fz_context *ctx, const char *path, const char *format, co
return fz_new_svg_writer(ctx, path, options);
if (!fz_strcasecmp(format, "png"))
- return fz_new_pixmap_writer(ctx, path, options, "out-%04.png", 0, fz_save_pixmap_as_png);
+ return fz_new_png_pixmap_writer(ctx, path, options);
if (!fz_strcasecmp(format, "tga"))
- return fz_new_pixmap_writer(ctx, path, options, "out-%04.tga", 0, fz_save_pixmap_as_tga);
+ return fz_new_tga_pixmap_writer(ctx, path, options);
if (!fz_strcasecmp(format, "pam"))
- return fz_new_pixmap_writer(ctx, path, options, "out-%04.pam", 0, fz_save_pixmap_as_pam);
+ return fz_new_pam_pixmap_writer(ctx, path, options);
if (!fz_strcasecmp(format, "pnm"))
- return fz_new_pixmap_writer(ctx, path, options, "out-%04.pnm", 0, fz_save_pixmap_as_pnm);
+ return fz_new_pnm_pixmap_writer(ctx, path, options);
if (!fz_strcasecmp(format, "pgm"))
- return fz_new_pixmap_writer(ctx, path, options, "out-%04.pgm", 1, fz_save_pixmap_as_pnm);
+ return fz_new_pgm_pixmap_writer(ctx, path, options);
if (!fz_strcasecmp(format, "ppm"))
- return fz_new_pixmap_writer(ctx, path, options, "out-%04.ppm", 3, fz_save_pixmap_as_pnm);
+ return fz_new_ppm_pixmap_writer(ctx, path, options);
if (!fz_strcasecmp(format, "pbm"))
- return fz_new_pixmap_writer(ctx, path, options, "out-%04.pbm", 1, fz_save_pixmap_as_pbm);
+ return fz_new_pbm_pixmap_writer(ctx, path, options);
if (!fz_strcasecmp(format, "pkm"))
- return fz_new_pixmap_writer(ctx, path, options, "out-%04.pkm", 4, fz_save_pixmap_as_pkm);
+ return fz_new_pkm_pixmap_writer(ctx, path, options);
fz_throw(ctx, FZ_ERROR_GENERIC, "unknown output document format: %s", format);
}