Skip to content

Instantly share code, notes, and snippets.

@droyad
Created September 18, 2013 00:26
Show Gist options
  • Select an option

  • Save droyad/6602748 to your computer and use it in GitHub Desktop.

Select an option

Save droyad/6602748 to your computer and use it in GitHub Desktop.
Scale image
var size = image.Size;
var aspectRatio = size.Width / size.Height;
var newSize = aspectRatio > 1
? new SizeF(maxHeightOrWidth, maxHeightOrWidth / aspectRatio)
: new SizeF(maxHeightOrWidth * aspectRatio, maxHeightOrWidth);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment