StiImage does not "center-align" image

Stimulsoft Reports.WPF discussion
Post Reply
Superwaxer
Posts: 6
Joined: Thu Jul 12, 2012 9:15 pm

StiImage does not "center-align" image

Post 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
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: StiImage does not "center-align" image

Post 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.
Superwaxer
Posts: 6
Joined: Thu Jul 12, 2012 9:15 pm

Re: StiImage does not "center-align" image

Post 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
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: StiImage does not "center-align" image

Post 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.
Post Reply