c# resize image keep aspect ratio
using System.Drawing;
public static Size ResizeKeepAspect(this Size src, int maxWidth, int maxHeight, bool enlarge = false)
{
maxWidth = enlarge ? maxWidth : Math.Min(maxWidth, src.Width);
maxHeight = enlarge ? maxHeight : Math.Min(maxHeight, src.Height);
decimal rnd = Math.Min(maxWidth / (decimal)src.Width, maxHeight / (decimal)src.Height);
return new Size((int)Math.Round(src.Width * rnd), (int)Math.Round(src.Height * rnd));
}
Also in C#:
- snake game
- c# loop string array
- print line in python
- unity rigidbody addforce
- The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located.
- mongodb c# batch find
- datatable return column names
- unity html get request
- c# param exception
- unity persistent data
- c# download string url
- How to get number of months between 2 dates c#
- unity check when clicked on object
- start up file in asp.net core
- unity pro version free download
- conditional compilation c#
- ecs get specific entities with component
- web api startup add imemory cache object
- Instantiate c#
- how to convert object in string JSON c#
- c# math to radiant
- how to generate random numbers in c#
- unity multiply xyz of two vectors
- C# get all child classes of a class