lunasvg icon indicating copy to clipboard operation
lunasvg copied to clipboard

After calling the function Document::scale() the original SVG canvas is not recalculated

Open rossanoparis opened this issue 2 years ago • 3 comments

After calling the function Document::scale() the original SVG canvas is not recalculated, this leads to a wrong bitmap size calling this function: auto bitmap = document->renderToBitmap();

image

Regards Rossano

rossanoparis avatar Aug 18 '22 13:08 rossanoparis

Use Document::render instead.

Example :

2x scale


Matrix matrix;
matrix.scale(2.0, 2.0);

Box box(0, 0, document->width(), document->height());
box.transform(matrix);

auto width ​= static_cast<int>(std::ceil(box.x + box.w));
auto height = static_cast<int>(std::ceil(box.y + box.h));

Bitmap bitmap(width, height);
bitmap.clear(0xFFFFFFFF); // white
document->render(bitmap, matrix);

sammycage avatar Aug 18 '22 18:08 sammycage

@sammycage Thank you

It works as expected

rossanoparis avatar Aug 19 '22 08:08 rossanoparis

@hobbitdev See https://github.com/sammycage/lunasvg/issues/96#issuecomment-1220314547

sammycage avatar Aug 19 '22 09:08 sammycage