We often have to change the size of an image while preserving the aspect ratio, the trivial function that photoshop has got us used to take for granted, constraint Proportion and go!
Here is a function to the rescue: GetNewsize Public Function (ByVal originalsize As Size, ByVal DesiredSize As Size) As Size Dim newSize As Size
'calculate the new size Dim
nPercentW As Single = DesiredSize.Width / OriginalSize.Width
nPercentH Dim As Single = DesiredSize.Height / OriginalSize.Height nPercent Dim As Single = IIf (nPercentH newSize = New Size (* OriginalSize.Width nPercent, OriginalSize.Height nPercent *)
'Return
newSize End Function
< nPercentW, nPercentH, nPercentW)