summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-09-04 15:56:09 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-09-04 15:56:09 (GMT)
commit560a4234e0a2787b5ba63445a76e7605a13f8d0c (patch)
tree5b09b549ce48b96b6e5261ea1face398ee81645c /gfx
parentf610e9857baf67d75043ed3a90accb3a7d7cc176 (diff)
downloadeeshow-560a4234e0a2787b5ba63445a76e7605a13f8d0c.zip
eeshow-560a4234e0a2787b5ba63445a76e7605a13f8d0c.tar.gz
eeshow-560a4234e0a2787b5ba63445a76e7605a13f8d0c.tar.bz2
gfx/cro.c: round up image and PDF sizes, to prevent accidental clipping
Diffstat (limited to 'gfx')
-rw-r--r--gfx/cro.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/gfx/cro.c b/gfx/cro.c
index 52c9f0b..27bf437 100644
--- a/gfx/cro.c
+++ b/gfx/cro.c
@@ -543,9 +543,9 @@ void cro_get_size(const struct cro_ctx *cc, int *w, int *h, int *x, int *y)
*x = xmin;
*y = ymin;
if (w)
- *w = cd(cc, bw);
+ *w = ceil(cd(cc, bw));
if (h)
- *h = cd(cc, bh);
+ *h = ceil(cd(cc, bh));
// fprintf(stderr, "%dx%d%+d%+d\n", *w, *h, xmin, ymin);
}
@@ -655,8 +655,8 @@ static int cr_pdf_end(void *ctx)
end_common(cc, &w, &h, NULL, NULL);
- w = (w + 15) >> 4;
- h = (h + 15) >> 4;
+ w = ((w + 15) >> 4) + ceil(0.5 * cc->scale);
+ h = ((h + 15) >> 4) + ceil(0.5 * cc->scale);
if (cc->toc)
cc->s = cairo_pdf_surface_create_for_stream(stream_to_pdftoc,
@@ -749,6 +749,9 @@ uint32_t *cro_img_end(struct cro_ctx *cc, int *w, int *h, int *stride)
*stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, *w);
data = alloc_size(*stride * *h);
+ w += 2; /* line width */
+ h += 2;
+
cc->s = cairo_image_surface_create_for_data((unsigned char *) data,
CAIRO_FORMAT_RGB24, *w, *h, *stride);
cc->cr = cairo_create(cc->s);