summaryrefslogtreecommitdiff
path: root/include/mupdf/fitz/output.h
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-10-11 21:10:21 +0100
committerRobin Watts <robin.watts@artifex.com>2016-10-12 12:37:48 +0100
commit80308eae9964e71b66a18f3de6ebcd2ebf0d306b (patch)
tree6aa51f6f53fca59d3c7afcb727f36cf627249e7a /include/mupdf/fitz/output.h
parent7de80f5eea6c9475b1db2b4fd905fd69ed3795e7 (diff)
downloadmupdf-80308eae9964e71b66a18f3de6ebcd2ebf0d306b.tar.xz
Regularize band writer interface.
We have various functions that, for different image formats, write a header, then a band, then (sometimes) a trailer. Push them all through a single interface. This change also fixes potential problems caused by the trailer writing being an implicit destructor, which can cause problems in cleanup code if the trailer writing throws an error.
Diffstat (limited to 'include/mupdf/fitz/output.h')
-rw-r--r--include/mupdf/fitz/output.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/mupdf/fitz/output.h b/include/mupdf/fitz/output.h
index d4abd712..ffa140f9 100644
--- a/include/mupdf/fitz/output.h
+++ b/include/mupdf/fitz/output.h
@@ -164,4 +164,37 @@ void fz_new_output_context(fz_context *ctx);
void fz_drop_output_context(fz_context *ctx);
fz_output_context *fz_keep_output_context(fz_context *ctx);
+/*
+ fz_band_writer
+*/
+typedef struct fz_band_writer_s fz_band_writer;
+
+typedef void (fz_write_header_fn)(fz_context *ctx, fz_band_writer *writer);
+typedef void (fz_write_band_fn)(fz_context *ctx, fz_band_writer *writer, int stride, int band_start, int bandheight, const unsigned char *samples);
+typedef void (fz_write_trailer_fn)(fz_context *ctx, fz_band_writer *writer);
+typedef void (fz_drop_band_writer_fn)(fz_context *ctx, fz_band_writer *writer);
+
+struct fz_band_writer_s
+{
+ fz_drop_band_writer_fn *drop;
+ fz_write_header_fn *header;
+ fz_write_band_fn *band;
+ fz_write_trailer_fn *trailer;
+ fz_output *out;
+ int w;
+ int h;
+ int n;
+ int alpha;
+ int xres;
+ int yres;
+ int pagenum;
+};
+
+fz_band_writer *fz_new_band_writer_of_size(fz_context *ctx, size_t size, fz_output *out);
+#define fz_new_band_writer(C,M,O) ((M *)Memento_label(fz_new_band_writer_of_size(ctx, sizeof(M), O), #M))
+void fz_write_header(fz_context *ctx, fz_band_writer *writer, int w, int h, int n, int alpha, int xres, int yres, int pagenum);
+void fz_write_band(fz_context *ctx, fz_band_writer *writer, int stride, int band_start, int bandheight, const unsigned char *samples);
+void fz_write_trailer(fz_context *ctx, fz_band_writer *writer);
+void fz_drop_band_writer(fz_context *ctx, fz_band_writer *writer);
+
#endif