labelTest.text = @"This is my Teststring.This is my Teststring.This is my Teststring.This is my Teststring.This is my Teststring.This is my Teststring."; labelTest.numberOfLines = 0; [labelTest sizeToFit];
scale
How to resize a image proportionally with CSS
To resize a image proportionally with CSS, simply set either width or height to auto. This should also work if the img html tag has width and height attributes set.
img.resize{ width:200px; height: auto; }
How to fit image size to div size in HTML
To fit image size to div size in HTML you need to set max-width and max-height without applying an explicit width or height.
Sample HTML
max-width:100%; max-height:100%;
How to scale a Size Object by percentage in C# and VB.NET
To scale a Size Object by percentage in C# and VB.NET you can use the following snippet.
Sample C#
public static Size Scale(this Size size, float scalePercent) { if (Math.Abs(scalePercent - 1) < float.Epsilon) { return size; } var height = (int) (size.Height*(scalePercent/100)); var width = (int)(size.Width * (scalePercent / 100)); return new Size(width, height); }
Sample VB.NET
<System.Runtime.CompilerServices.Extension> _ Public Shared Function Scale(size As Size, scalePercent As Single) As Size If Math.Abs(scalePercent - 1) < Single.Epsilon Then Return size End If Dim height = CInt(size.Height * (scalePercent / 100)) Dim width = CInt(size.Width * (scalePercent / 100)) Return New Size(width, height) End Function
How to scale a Size variable in C# or VB.NET
To scale a Size variable in C# or VB.NET you can use the following Extension Method.
Sample C#
public static Size Scale(this Size size, float scaleInPercent) { if (Math.Abs(scaleInPercent - 1) < float.Epsilon) { return size; } var height = (int)(size.Height * scaleInPercent); var width = (int)(size.Width * scaleInPercent); return new Size(width, height); }
Sample VB.NET
<System.Runtime.CompilerServices.Extension> _ Public Shared Function Scale(size As Size, scaleInPercent As Single) As Size If Math.Abs(scaleInPercent - 1) < Single.Epsilon Then Return size End If Dim height = CInt(size.Height * scaleInPercent) Dim width = CInt(size.Width * scaleInPercent) Return New Size(width, height) End Function