summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2014-11-19 15:03:33 +0100
committerTor Andersson <tor.andersson@artifex.com>2014-12-03 12:25:52 +0100
commitbd11f27be2e8f6e06ee664ebcc40b17f78a2e9d4 (patch)
treed9a7fd6c83971deec0ef62d419dad37aad793c68 /source
parent105d9d938396f867607406167c6e78f18625004d (diff)
downloadmupdf-bd11f27be2e8f6e06ee664ebcc40b17f78a2e9d4.tar.xz
html: Limit image size to fit the page.
Diffstat (limited to 'source')
-rw-r--r--source/html/layout.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/source/html/layout.c b/source/html/layout.c
index 8285b829..acc3d71b 100644
--- a/source/html/layout.c
+++ b/source/html/layout.c
@@ -321,12 +321,18 @@ static void generate_boxes(html_document *doc, fz_xml *node, struct box *top, st
}
}
-static void measure_image(fz_context *ctx, struct flow *node, float em)
+static void measure_image(fz_context *ctx, struct flow *node, float w, float h)
{
+ float xs = 1, ys = 1, s = 1;
node->x = 0;
node->y = 0;
- node->w = node->image->w;
- node->h = node->image->h;
+ if (node->image->w > w)
+ xs = w / node->image->w;
+ if (node->image->h > h)
+ ys = h / node->image->h;
+ s = fz_min(xs, ys);
+ node->w = node->image->w * s;
+ node->h = node->image->h * s;
}
static void measure_word(fz_context *ctx, struct flow *node, float em)
@@ -476,7 +482,7 @@ static void layout_flow(fz_context *ctx, struct box *box, struct box *top, float
for (node = box->flow_head; node; node = node->next)
if (node->type == FLOW_IMAGE)
- measure_image(ctx, node, em);
+ measure_image(ctx, node, top->w, page_h);
else
measure_word(ctx, node, em);