From 594e09b250ef59c05de6faf0b01436f47ae796ce Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 16 Aug 2018 17:20:53 +0100 Subject: [PATCH] SVG: Rescale image before transforming to ensure that it is the correct size --- modules/juce_gui_basics/drawables/juce_SVGParser.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/juce_gui_basics/drawables/juce_SVGParser.cpp b/modules/juce_gui_basics/drawables/juce_SVGParser.cpp index 395b41c9f3..657bd12cb6 100644 --- a/modules/juce_gui_basics/drawables/juce_SVGParser.cpp +++ b/modules/juce_gui_basics/drawables/juce_SVGParser.cpp @@ -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 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));