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/tools/murun.c | 4 +--- source/tools/pdfextract.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'source/tools') diff --git a/source/tools/murun.c b/source/tools/murun.c index c2a9f0bc..6e6e2719 100644 --- a/source/tools/murun.c +++ b/source/tools/murun.c @@ -1881,12 +1881,10 @@ static void ffi_Image_toPixmap(js_State *J) { fz_context *ctx = js_getcontext(J); fz_image *image = js_touserdata(J, 0, "fz_image"); - int w = js_isnumber(J, 1) ? js_tonumber(J, 1) : image->w; - int h = js_isnumber(J, 2) ? js_tonumber(J, 2) : image->h; fz_pixmap *pixmap = NULL; fz_try(ctx) - pixmap = fz_get_pixmap_from_image(ctx, image, w, h); + pixmap = fz_get_pixmap_from_image(ctx, image, NULL, NULL, NULL, NULL); fz_catch(ctx) rethrow(J); diff --git a/source/tools/pdfextract.c b/source/tools/pdfextract.c index 74b3654e..3f79137a 100644 --- a/source/tools/pdfextract.c +++ b/source/tools/pdfextract.c @@ -72,7 +72,7 @@ static void saveimage(int num) /* TODO: detect DCTD and save as jpeg */ image = pdf_load_image(ctx, doc, ref); - pix = fz_get_pixmap_from_image(ctx, image, 0, 0); + pix = fz_get_pixmap_from_image(ctx, image, NULL, NULL, 0, 0); fz_drop_image(ctx, image); snprintf(buf, sizeof(buf), "img-%04d", num); -- cgit v1.2.3