You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously we have used the following code in the c bindings
var fitTo = new DrawingUtilitiesPInvokes.resvg_fit_to();
fitTo._fitToType = 1;
fitTo._value = (float)width;
DrawingUtilitiesPInvokes.resvg_render(renderTree, fitto, (uint)width, (uint)height, pBytes);
But now in 0.44.0, the Fit To zoom does not exist anymore. I've tried using some transform code and using the Bounds, but not managed to replicate the icons as they were. Can anyone offer any assistance in replicating this functionality? I would very much like to update our dependency to 0.44.0
DrawingUtilitiesPInvokes.resvg_transform transform = DrawingUtilitiesPInvokes.resvg_transform_identity();
floatfWidth = width;
floatfHeight = height;
// Ensures the scaling is correct
DrawingUtilitiesPInvokes.resvg_rect svgBounds = new DrawingUtilitiesPInvokes.resvg_rect();
if (DrawingUtilitiesPInvokes.resvg_get_image_bbox(renderTree, ref svgBounds))
{
float maxSize = Math.Max(fWidth, fHeight);
float maxBoundsSize = Math.Max(svgBounds.width, svgBounds.height);
float scale = maxSize / maxBoundsSize;
transform = new DrawingUtilitiesPInvokes.resvg_transform()
{
a = scale,
b = 0,
c = 0,
d = scale,
e = -svgBounds.x * scale
f = -svgBounds.y * scale
};
}
GCHandle pinnedArray = GCHandle.Alloc(pixmap, GCHandleType.Pinned);
IntPtr pBytes = pinnedArray.AddrOfPinnedObject();
DrawingUtilitiesPInvokes.resvg_render(renderTree, transform, (uint)width, (uint)height, pBytes);
The text was updated successfully, but these errors were encountered:
Thanks for getting back to me so quickly @RazrFalcon,
Our software has panels and toolbars which allow customization with an SVG of any size. This is what it currently looks like using 0.14.0
0.14.0 (current)
Using 0.44.0 (with an identity transform)
Using 0.44.0 (with my above transform calculation code)
Looks good, a bit more zoomed in than before? Some others do not look good however, as below;
I would like our software to render the icons identically with 0.14.0 and 0.44.0, so I need an accurate way to replicate the FitTo using a transform (as far as I can see)
Can you share a single SVG icon of yours? Or at least the first element of it, i.e. the <svg ... one.
Also, FitTo was removed in 0.33.0, so you can try 0.32 for now.
Overall, it's hard to say what is wrong. For starters, you should use resvg_get_image_size instead of resvg_get_image_bbox. This should help.
And use only width for scale calculation instead of width or height.
Previously we have used the following code in the c bindings
But now in 0.44.0, the Fit To zoom does not exist anymore. I've tried using some transform code and using the Bounds, but not managed to replicate the icons as they were. Can anyone offer any assistance in replicating this functionality? I would very much like to update our dependency to 0.44.0
The text was updated successfully, but these errors were encountered: