lunasvg
lunasvg copied to clipboard
After calling the function Document::scale() the original SVG canvas is not recalculated
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();
Regards Rossano
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 Thank you
It works as expected
@hobbitdev See https://github.com/sammycage/lunasvg/issues/96#issuecomment-1220314547