From 76b7cddba1d97c22b3a357e2da2f183b3ea1434b Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sat, 20 Mar 2021 12:54:32 +0000 Subject: [PATCH] better rounding in tile calcs --- libvips/foreign/jp2kload.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libvips/foreign/jp2kload.c b/libvips/foreign/jp2kload.c index dbd9d38d..8d22d0fe 100644 --- a/libvips/foreign/jp2kload.c +++ b/libvips/foreign/jp2kload.c @@ -592,8 +592,10 @@ vips_foreign_load_jp2k_generate( VipsRegion *out, /* jp2k get smaller with the layer size. */ - int tile_width = jp2k->info->tdx / jp2k->shrink; - int tile_height = jp2k->info->tdy / jp2k->shrink; + int tile_width = VIPS_ROUND_UINT( + (double) jp2k->info->tdx / jp2k->shrink ); + int tile_height = VIPS_ROUND_UINT( + (double) jp2k->info->tdy / jp2k->shrink ); /* ... so tiles_across is always the same. */