Closed SlavaSharunov closed 5 years ago
I can do it with proper scaling of the image. Just need to calculate it: for example, the width of my canvas is 300, width of the svg is 175. scale = 300/175=1.7143 ->
nsvgRasterize(rast, image, 0, 0, 1.7143, img_data.data(), w, h, w * 4);
I have used as well not merged solution for independent x-y scaling proposed in https://github.com/memononen/nanosvg/pull/68
Hence the full solution is:
scaleX = width_of_canvas / (float)image->width; scaleY = height_of_canvas / (float)image->height; nsvgRasterizeXY(rast, image, 0, 0, scaleX, scaleY, img_data.data(), w, h, w * 4);
Think I can close the issue.
Hello Mikko, hello everyone
I use the library to render SVG in C++ project. Rendering is done with help of GDI+. First I parse the .svg file, rasterize it with following parameters:
nsvgRasterize(rast, image, 0, 0, 1, img_data.data(), w, h, w * 4);
, wherew = (int)image->width; h = (int)image->height;
and img_data is a vector of UINT8. Then I create a bitmap from the bits array and draw it on HDC.The advantage of vector graphics as I know is that scaling the picture wont give some loss in a quality of the image. But when I try to scale the drawn image (with mouse as it could be done in for example graphical editor) I see the quality is getting worse and worse...
Is there any solution or the library does not support such feature?
I will be very thankful for every advice from your side.
Thank you