diff options
author | Robin Watts <robin.watts@artifex.com> | 2017-10-09 17:36:36 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2017-10-13 15:57:25 +0100 |
commit | 680594660b6b680326cd56fe5ea604a0b55efcfa (patch) | |
tree | 5dc41ad31fd8d61f0633728c870750c9cbd11389 /include | |
parent | 167da6144dc8bcafc1f1476d73b3b6d18541a8a8 (diff) | |
download | mupdf-680594660b6b680326cd56fe5ea604a0b55efcfa.tar.xz |
Add fz_deflate family of functions.
This gives us a friendlier interface to zlib.
Simplifies PNG output and PCLM output code.
Diffstat (limited to 'include')
-rw-r--r-- | include/mupdf/fitz.h | 1 | ||||
-rw-r--r-- | include/mupdf/fitz/compress.h | 50 |
2 files changed, 51 insertions, 0 deletions
diff --git a/include/mupdf/fitz.h b/include/mupdf/fitz.h index 9b6d6aa9..9f697c8a 100644 --- a/include/mupdf/fitz.h +++ b/include/mupdf/fitz.h @@ -23,6 +23,7 @@ extern "C" { /* I/O */ #include "mupdf/fitz/buffer.h" #include "mupdf/fitz/stream.h" +#include "mupdf/fitz/compress.h" #include "mupdf/fitz/compressed-buffer.h" #include "mupdf/fitz/filter.h" #include "mupdf/fitz/output.h" diff --git a/include/mupdf/fitz/compress.h b/include/mupdf/fitz/compress.h new file mode 100644 index 00000000..cfd4ed1a --- /dev/null +++ b/include/mupdf/fitz/compress.h @@ -0,0 +1,50 @@ +#ifndef MUPDF_FITZ_COMPRESS_H +#define MUPDF_FITZ_COMPRESS_H + +#include "mupdf/fitz/system.h" + +typedef enum +{ + FZ_DEFLATE_NONE = 0, + FZ_DEFLATE_BEST_SPEED = 1, + FZ_DEFLATE_BEST = 9, + FZ_DEFLATE_DEFAULT = -1 +} fz_deflate_level; + +/* + fz_deflate_bound: Returns the upper bound on the + size of flated data of length size. + */ +size_t fz_deflate_bound(fz_context *ctx, size_t size); + +/* + fz_deflate: Compress source_length bytes of data starting + at source, into a buffer of length *destLen, starting at dest. + *compressed_length will be updated on exit to contain the size + actually used. + */ +void fz_deflate(fz_context *ctx, unsigned char *dest, size_t *compressed_length, const unsigned char *source, size_t source_length, fz_deflate_level level); + +/* + fz_new_deflated_data: Compress source_length bytes of data starting + at source, into a new memory block malloced for that purpose. + *compressed_length is updated on exit to contain the size used. + Ownership of the block is returned from this function, and the + caller is therefore responsible for freeing it. The block may be + considerably larger than is actually required. The caller is + free to fz_realloc it down if it wants to. +*/ +unsigned char *fz_new_deflated_data(fz_context *ctx, size_t *compressed_length, const unsigned char *source, size_t source_length, fz_deflate_level level); + +/* + fz_new_deflated_data_from_buffer: Compress the contents of a fz_buffer into a + new block malloced for that purpose. *compressed_length is updated + on exit to contain the size used. Ownership of the block is + returned from this function, and the caller is therefore responsible + for freeing it. The block may be considerably larger than is + actually required. The caller is free to fz_realloc it down if it + wants to. +*/ +unsigned char *fz_new_deflated_data_from_buffer(fz_context *ctx, size_t *compressed_length, fz_buffer *buffer, fz_deflate_level level); + +#endif |