RenderImage KeepAspectRatio

Posted by: m.lindinger on 28 August 2020, 3:39 am EST

    • Post Options:
    • Link

    Posted 28 August 2020, 3:39 am EST

    Hello,

    we are adding a RenderImage to a C1PrintDocument.

    By default, the RenderImage has settings to keep the aspect ratio if you resize width or height.

    How can I change this behaviour that the RenderImage is stretched horizontally and vertically?

    What I have tried yet:

    
    
    			    Dim ri = New RenderImage(Image.FromStream(stream))
                                Dim customAlign = New ImageAlign()
                                customAlign .KeepAspectRatio = False
                                customAlign .StretchHorz = True
                                customAlign .StretchVert = True
                                customAlign .AlignHorz = ImageAlignHorzEnum.Center
                                customAlign .AlignVert = ImageAlignVertEnum.Center
                                ri.Style.ImageAlign = specialAlign
    
    

    Unfortunately, this does not work. The image is always place on the top left and keeps aspect ratio if I resize it.

    Thanks for help in advance.

    Michael

  • Posted 30 August 2020, 10:53 pm EST

    Hi Michael,

    Which build version are you using? Are you using the latest 2020v2 builds?

    Also, can you please share a video of the issue, for us to see.

    Thanks,

  • Posted 31 August 2020, 3:27 am EST - Updated 3 October 2022, 11:48 pm EST

    Hello Ruchir,

    I am using

    • "

    • “C1Chart.4.dll: 4.0.20192.658”

    • "C1Chart.Extended.4.dll :4.0.20192.658 "

    • “C1Report.4.dll: 4.0.20192.375”

    "

    However I also tried it with version 4.0.20202.716 (C1Chart.4.dll and C1Chart.Extended.dll) and 4.0.20202.438 (C1Report-4.dll)

    I cannot provide you a video because it is only a PDF-Report as mentioned above. As you can see in the attached example, I rotated the chart by 270° . What I want to have now is the ability to stretch the rotated chart only vertically to fill the white area on the bottom.

    However, If I do so, the image is also stretched horizontally even if I override the property “KeepAspectRatio” by setting it to false

  • Posted 31 August 2020, 5:46 pm EST - Updated 3 October 2022, 11:48 pm EST

    Hi,

    I tested the behavior and setting the StretchHorz/StretchVert properties to True/False respectively, I can see the RenderImage stretched properly. See attached image showing the chart resized horizontally.



    Also, attached is the sample application I used to test. In case, there is anything else you are doing, please modify the application and share back.

    Regards,

    WpfChartInReport.zip

  • Posted 27 November 2020, 4:24 am EST

    Hi,

    your examples are okay for displaying charts in a window. However, within PdfReport, they behave the same as I described initially.

    However, I finally found a working solution. My post arose due to a requirement to rotate the chart within PdfReport and then stretch it to fill the empty space on the left side of the page in horizontal view. Using RenderTransform to rotate and keeping the default Alignment of the RenderImage finally made it work.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels