summaryrefslogtreecommitdiff
path: root/source/fitz/output-png.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2017-10-09 17:36:36 +0100
committerRobin Watts <robin.watts@artifex.com>2017-10-13 15:57:25 +0100
commit680594660b6b680326cd56fe5ea604a0b55efcfa (patch)
tree5dc41ad31fd8d61f0633728c870750c9cbd11389 /source/fitz/output-png.c
parent167da6144dc8bcafc1f1476d73b3b6d18541a8a8 (diff)
downloadmupdf-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 'source/fitz/output-png.c')
-rw-r--r--source/fitz/output-png.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/source/fitz/output-png.c b/source/fitz/output-png.c
index 38bfa778..d21bc59b 100644
--- a/source/fitz/output-png.c
+++ b/source/fitz/output-png.c
@@ -86,34 +86,18 @@ static void
png_write_icc(fz_context *ctx, png_band_writer *writer, const fz_colorspace *cs)
{
fz_output *out = writer->super.out;
- int size;
+ size_t size, csize;
fz_buffer *buffer = fz_icc_data_from_icc_colorspace(ctx, cs);
- unsigned char *data;
unsigned char *pos, *cdata, *chunk = NULL;
- uLong bound;
- uLongf csize;
- uLong long_size;
- int t;
- long_size = (uLong)fz_buffer_storage(ctx, buffer, &data);
+ /* Deflate the profile */
+ cdata = fz_new_deflated_data_from_buffer(ctx, &csize, buffer, FZ_DEFLATE_DEFAULT);
- if (!data)
+ if (!cdata)
return;
- /* Deflate the profile */
- bound = compressBound(long_size);
- cdata = fz_malloc(ctx, bound);
- csize = (uLongf)bound;
- t = compress(cdata, &csize, data, long_size);
- if (t != Z_OK)
- {
- fz_free(ctx, cdata);
- fz_throw(ctx, FZ_ERROR_GENERIC, "cannot deflate icc buffer");
- }
size = csize + strlen("MuPDF Profile") + 2;
- fz_var(cdata);
-
fz_try(ctx)
{
chunk = fz_calloc(ctx, size, 1);