We are using the Stimulsoft control for displaying a "report preview" to the user in WPF. The user has the ability to upload a unique logo that is displayed in the header of the report as well as the cover page. The logic behind the cover page image is as follows:
- - If the logo is larger than the bounds of the image box (StiImage) then it should be shrunk to fit
- If the logo is smaller than the bounds of the image box (StiImage) then it should keep its size and aspect ratio but appear in the center of the control both horizontally and vertically
Here is my code for doing this:
Code: Select all
var coverTitleBand = (StiBand)coverPage.Components["ReportCoverPageTitleBand"];
var coverImage = (StiImage)coverTitleBand.Components["CoverPageImage"];
coverImage.Image = System.Drawing.Image.FromStream(logo);
var imageControlSize = coverImage.GetActualSize();
if (coverImage.Image.Height > (imageControlSize.Height * 96) || coverImage.Image.Width > (imageControlSize.Width * 96))
coverImage.Stretch = true;
else
{
coverImage.Stretch = false;
coverImage.HorAlignment = StiHorAlignment.Center;
coverImage.VertAlignment = StiVertAlignment.Center;
}
I've also tried setting the "CanGrow" and "CanShrink" properties but to no avail. Any ideas on what could be causing the smaller images to appear in the top-left corner?
Thanks