summaryrefslogtreecommitdiff
path: root/source/fitz/output-png.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2017-03-22 14:38:35 +0100
committerRobin Watts <Robin.Watts@artifex.com>2017-03-23 17:09:19 -0400
commit031c7035652d3c967321c9c308dea7cfb1c0e6fa (patch)
tree58e1d638c18e935e7c98f0ec13034376582fc721 /source/fitz/output-png.c
parent185d530d3b3a6f8be63dd7cfc3f2b7784066707c (diff)
downloadmupdf-031c7035652d3c967321c9c308dea7cfb1c0e6fa.tar.xz
Add generic pixmap document writer.
Allow mutool convert to output all image formats we can write. Add sanity checks for pbm and pkm writers.
Diffstat (limited to 'source/fitz/output-png.c')
-rw-r--r--source/fitz/output-png.c71
1 files changed, 0 insertions, 71 deletions
diff --git a/source/fitz/output-png.c b/source/fitz/output-png.c
index de5500c9..c8972b25 100644
--- a/source/fitz/output-png.c
+++ b/source/fitz/output-png.c
@@ -299,74 +299,3 @@ fz_new_buffer_from_pixmap_as_png(fz_context *ctx, fz_pixmap *pix)
{
return png_from_pixmap(ctx, pix, 0);
}
-
-/* PNG output writer */
-
-typedef struct fz_png_writer_s fz_png_writer;
-
-struct fz_png_writer_s
-{
- fz_document_writer super;
- fz_draw_options options;
- fz_pixmap *pixmap;
- int count;
- char *path;
-};
-
-const char *fz_png_write_options_usage = "";
-
-static fz_device *
-png_begin_page(fz_context *ctx, fz_document_writer *wri_, const fz_rect *mediabox)
-{
- fz_png_writer *wri = (fz_png_writer*)wri_;
- return fz_new_draw_device_with_options(ctx, &wri->options, mediabox, &wri->pixmap);
-}
-
-static void
-png_end_page(fz_context *ctx, fz_document_writer *wri_, fz_device *dev)
-{
- fz_png_writer *wri = (fz_png_writer*)wri_;
- char path[PATH_MAX];
-
- fz_close_device(ctx, dev);
- fz_drop_device(ctx, dev);
-
- wri->count += 1;
-
- fz_format_output_path(ctx, path, sizeof path, wri->path, wri->count);
- fz_save_pixmap_as_png(ctx, wri->pixmap, path);
- fz_drop_pixmap(ctx, wri->pixmap);
- wri->pixmap = NULL;
-}
-
-static void
-png_drop_writer(fz_context *ctx, fz_document_writer *wri_)
-{
- fz_png_writer *wri = (fz_png_writer*)wri_;
- fz_drop_pixmap(ctx, wri->pixmap);
- fz_free(ctx, wri->path);
-}
-
-fz_document_writer *
-fz_new_png_writer(fz_context *ctx, const char *path, const char *options)
-{
- fz_png_writer *wri;
-
- wri = fz_malloc_struct(ctx, fz_png_writer);
- wri->super.begin_page = png_begin_page;
- wri->super.end_page = png_end_page;
- wri->super.drop_writer = png_drop_writer;
-
- fz_try(ctx)
- {
- fz_parse_draw_options(ctx, &wri->options, options);
- wri->path = fz_strdup(ctx, path ? path : "out-%04d.png");
- }
- fz_catch(ctx)
- {
- fz_free(ctx, wri);
- fz_rethrow(ctx);
- }
-
- return (fz_document_writer*)wri;
-}