Page 1 of 1

StiImage does not "center-align" image

Posted: Thu Jul 12, 2012 11:14 pm
by Superwaxer
Hey guys,

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
It mentions in the documentation that in order for an image to align in any position inside an image control the "Stretch" property must be set to false. However, regardless of whether the stretch property is set to false or not, it still aligns the logo in the top-left corner if it's smaller than the size of the image control. Is there something I'm missing?

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;
          }
What's peculiar is that when I have the EXACT SAME settings in the designer for the image control it alligns the image perfectly in the center both horizontally and vertically.

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

Re: StiImage does not "center-align" image

Posted: Mon Jul 16, 2012 11:23 am
by Alex K.
Hello,

We couldn't reproduce this bug.
Please send us a sample report with test data which reproduces the issue.

Thank you.

Re: StiImage does not "center-align" image

Posted: Wed Jul 18, 2012 8:19 pm
by Superwaxer
We managed to fix this issue by setting the "CanShrink" property to false. Turns out the entire image control was shrunk in the top-left corner - not just the image.

Thanks

Re: StiImage does not "center-align" image

Posted: Thu Jul 19, 2012 10:24 am
by HighAley
Hello.
Superwaxer wrote:We managed to fix this issue by setting the "CanShrink" property to false. Turns out the entire image control was shrunk in the top-left corner - not just the image.
It's a normal behaviour of the StiImage component. It shrinks to the content size.

Thank you.