From: buliabyak Date: Mon, 1 Sep 2008 20:54:33 +0000 (+0000) Subject: fix assert when exporting bug 171849 file, make sure small patterns are exported... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4db978f936a528ef0a6646c49eaa6eb5978d5ab2;p=inkscape.git fix assert when exporting bug 171849 file, make sure small patterns are exported properly by scaling them up (to use integer width/height) and then down --- diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 4a3dd11a6..0a12a5c5b 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -976,10 +976,14 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver width_scaler *= 1.25; height_scaler *= 1.25; } + +#define SUBPIX_SCALE 1000 + // Cairo requires an integer pattern surface width/height. // Subtract 0.5 to prevent small rounding errors from increasing pattern size by one pixel. - double surface_width = ceil(bbox_width_scaler * width_scaler * width - 0.5); - double surface_height = ceil(bbox_height_scaler * height_scaler * height - 0.5); + // Multiply by SUBPIX_SCALE to allow for less than a pixel precision + double surface_width = MAX(ceil(SUBPIX_SCALE * bbox_width_scaler * width_scaler * width - 0.5), 1); + double surface_height = MAX(ceil(SUBPIX_SCALE * bbox_height_scaler * height_scaler * height - 0.5), 1); TRACE(("surface size: %f x %f\n", surface_width, surface_height)); // create new rendering context CairoRenderContext *pattern_ctx = cloneMe(surface_width, surface_height);