From b944f16a564f8a31d9a064980318ad690be31f8e Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 7 Apr 2016 11:08:42 +0100 Subject: Partial image decode. Update the core fz_get_pixmap_from_image code to allow fetching a subarea of a pixmap. We pass in the required subarea, together with the transformation matrix for the whole image. On return, we have a pixmap at least as big as was requested, and the transformation matrix is updated to map the supplied area to the correct place on the screen. The draw device is updated to use this as required. Everywhere else passes NULLs in, and so gets unchanged behaviour. The standard 'get_pixmap' function has been updated to decode just the required areas of the bitmaps. This means that banded rendering of pages will decode just the image subareas that are required for each band, limiting the memory use. The downside to this is that each band will redecode the image again to extract just the section we want. The image subareas are put into the fz_store in the same way as full images. Currently image areas in the store are only matched when they match exactly; subareas are not identified as being able to use existing images. --- source/fitz/stream-read.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'source/fitz/stream-read.c') diff --git a/source/fitz/stream-read.c b/source/fitz/stream-read.c index 2ebd5ad6..2ace7b1f 100644 --- a/source/fitz/stream-read.c +++ b/source/fitz/stream-read.c @@ -27,6 +27,26 @@ fz_read(fz_context *ctx, fz_stream *stm, unsigned char *buf, int len) return count; } +static unsigned char skip_buf[4096]; + +int fz_skip(fz_context *ctx, fz_stream *stm, int len) +{ + int count, l, total = 0; + + while (len) + { + l = len; + if (l > sizeof(skip_buf)) + l = sizeof(skip_buf); + count = fz_read(ctx, stm, skip_buf, l); + total += count; + if (count < l) + break; + len -= count; + } + return total; +} + fz_buffer * fz_read_all(fz_context *ctx, fz_stream *stm, int initial) { -- cgit v1.2.3