+/**
+ * @brief Set an image to image view, scaled-down to no more than the dimensions passed in.
+ *
+ * Uses SHRINK_TO_FIT which ensures the resulting image is
+ * smaller than or equal to the specified dimensions while preserving its original aspect ratio.
+ */
+void SetImageFittedInBox( ImageView& imageView, Property::Map& shaderEffect, const char * const imagePath, int maxWidth, int maxHeight )
+{
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::IMAGE;
+ map[ImageVisual::Property::URL] = imagePath;
+ // Load the image nicely scaled-down to fit within the specified max width and height:
+ map[ImageVisual::Property::DESIRED_WIDTH] = maxWidth;
+ map[ImageVisual::Property::DESIRED_HEIGHT] = maxHeight;
+ map[ImageVisual::Property::FITTING_MODE] = FittingMode::SHRINK_TO_FIT;
+ map[ImageVisual::Property::SAMPLING_MODE] = SamplingMode::BOX_THEN_LINEAR;
+ map.Merge( shaderEffect );
+
+ imageView.SetProperty( ImageView::Property::IMAGE, map );
+}