In 2021r2.1, I have a PNG image that I am loading into the IDE using Graphics.DrawPicture within DrawControlInLayout. My code for doing this:
Dim Pic As Picture = PictureProperty("ImagePNG") g.DrawPicture(Pic, 0, 0, g.Width, g.Height, 0, 0, Pic.Width, Pic.Height)
For images that are square or a close to square aspect, this works great and will scale the image to the shape of the control fine. However, images that are more rectangular in aspect are being cropped instead of being stretched to fit the dimensions of the control. For example:
This is the image that is being added to the control:
And this is how it’s being displayed in the IDE:
I have tried scaling the image with this code which i use for other images:
Dim factorwidth As Double = g.Width / Pic.Width Dim factorheight As Double = g.Height / Pic.Height Dim factor As Double = min(factorwidth, factorheight) Dim w As Integer = Pic.Width * factor Dim h As Integer = Pic.Height * factor Dim NewPic As New Picture( w, h ) g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.DrawPicture( Pic, 0, 0, w, h, 0, 0, Pic.Width, Pic.Height ) Pic = NewPic
But this is only making the image worse and instead reducing the image by about 50% scale and still being cropped at the same points.