1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

SVG: Rescale image before transforming to ensure that it is the correct size

This commit is contained in:
ed 2018-08-16 17:20:53 +01:00
parent b8b77df0ed
commit 594e09b250

View file

@ -1201,11 +1201,13 @@ private:
auto* di = new DrawableImage();
setCommonAttributes (*di, xml);
di->setImage (image);
di->setTransformToFit ({ (float) xml->getDoubleAttribute ("x", 0.0), (float) xml->getDoubleAttribute ("y", 0.0),
(float) xml->getDoubleAttribute ("width", 0.0), (float) xml->getDoubleAttribute ("height", 0.0) },
RectanglePlacement (parsePlacementFlags (xml->getStringAttribute ("preserveAspectRatio").trim())));
Rectangle<float> imageBounds ((float) xml->getDoubleAttribute ("x", 0.0), (float) xml->getDoubleAttribute ("y", 0.0),
(float) xml->getDoubleAttribute ("width", image.getWidth()), (float) xml->getDoubleAttribute ("height", image.getHeight()));
di->setImage (image.rescaled ((int) imageBounds.getWidth(), (int) imageBounds.getHeight()));
di->setTransformToFit (imageBounds, RectanglePlacement (parsePlacementFlags (xml->getStringAttribute ("preserveAspectRatio").trim())));
if (additionalTransform != nullptr)
di->setTransform (di->getTransform().followedBy (transform).followedBy (*additionalTransform));