diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-09-04 14:25:41 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-10-05 15:50:37 +0100 |
commit | 9463d7a87f46c4f50cb1074424c9c3ecda7a5da1 (patch) | |
tree | d4de9e755b687811c5818533652d8f68d7b23188 /pdf/pdf_image.c | |
parent | 68e788fa455c780b83bffa33228ff3f45bebc1d1 (diff) | |
download | mupdf-9463d7a87f46c4f50cb1074424c9c3ecda7a5da1.tar.xz |
Refactor compressed stream loading.
Refactor 'short stopped' image stream loading into fz_compressed_buffer
loading. Nicer overall, and reflects the fact that this can be used
for non-image streams that we want to hold compressed in memory (for
instance for shading streams).
This is a preparatory step for pdfwrite, and enables further shading
memory use optimisations.
Remove unused jbig2 function pointer from the fz_compression_params
(previously fz_image_params) structure to avoid confusion.
Diffstat (limited to 'pdf/pdf_image.c')
-rw-r--r-- | pdf/pdf_image.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c index 03872726..262be821 100644 --- a/pdf/pdf_image.c +++ b/pdf/pdf_image.c @@ -234,7 +234,7 @@ pdf_free_image(fz_context *ctx, fz_storable *image_) if (image == NULL) return; fz_drop_pixmap(ctx, image->tile); - fz_drop_buffer(ctx, image->buffer); + fz_free_compressed_buffer(ctx, image->buffer); fz_drop_colorspace(ctx, image->base.colorspace); fz_drop_image(ctx, image->base.mask); fz_free(ctx, image); @@ -284,7 +284,7 @@ pdf_image_get_pixmap(fz_context *ctx, fz_image *image_, int w, int h) while (key.factor > 0); /* We need to make a new one. */ - stm = pdf_open_image_decomp_stream(ctx, image->buffer, &image->params, &factor); + stm = fz_open_image_decomp_stream(ctx, image->buffer, &factor); return decomp_image_from_stream(ctx, stm, image, 0, 0, factor, 1); } @@ -418,7 +418,6 @@ pdf_load_image_imp(pdf_document *xref, pdf_obj *rdb, pdf_obj *dict, fz_stream *c } /* Now, do we load a ref, or do we load the actual thing? */ - image->params.type = PDF_IMAGE_RAW; FZ_INIT_STORABLE(&image->base, 1, pdf_free_image); image->base.get_pixmap = pdf_image_get_pixmap; image->base.w = w; @@ -429,14 +428,13 @@ pdf_load_image_imp(pdf_document *xref, pdf_obj *rdb, pdf_obj *dict, fz_stream *c image->imagemask = imagemask; image->usecolorkey = usecolorkey; image->base.mask = mask; - image->params.colorspace = image->base.colorspace; /* Uses the same ref as for the base one */ if (!indexed && !cstm) { /* Just load the compressed image data now and we can * decode it on demand. */ int num = pdf_to_num(dict); int gen = pdf_to_gen(dict); - image->buffer = pdf_load_image_stream(xref, num, gen, num, gen, &image->params); + image->buffer = pdf_load_compressed_stream(xref, num, gen); break; /* Out of fz_try */ } @@ -543,19 +541,18 @@ pdf_load_jpx(pdf_document *xref, pdf_obj *dict, pdf_image *image) fz_drop_pixmap(ctx, img); fz_rethrow(ctx); } - image->params.type = PDF_IMAGE_RAW; FZ_INIT_STORABLE(&image->base, 1, pdf_free_image); image->base.get_pixmap = pdf_image_get_pixmap; image->base.w = img->w; image->base.h = img->h; image->base.colorspace = colorspace; + image->buffer = NULL; image->tile = img; image->n = img->n; image->bpc = 8; image->interpolate = 0; image->imagemask = 0; image->usecolorkey = 0; - image->params.colorspace = colorspace; /* Uses the same ref as for the base one */ } static int @@ -563,7 +560,7 @@ pdf_image_size(fz_context *ctx, pdf_image *im) { if (im == NULL) return 0; - return sizeof(*im) + fz_pixmap_size(ctx, im->tile) + (im->buffer ? im->buffer->cap : 0); + return sizeof(*im) + fz_pixmap_size(ctx, im->tile) + (im->buffer && im->buffer->buffer ? im->buffer->buffer->cap : 0); } fz_image * |