Skip to content

Instantly share code, notes, and snippets.

@Splat
Last active December 17, 2015 02:19
Show Gist options
  • Save Splat/5534678 to your computer and use it in GitHub Desktop.
Save Splat/5534678 to your computer and use it in GitHub Desktop.
Monotouch normalize image to orientation for shipping to external applications | servers which may not respect the EXIF data.
public static UIImage RotateImage (this UIImage image)
{
if (image.Orientation == UIImageOrientation.Up) return image;
UIGraphics.BeginImageContextWithOptions(image.Size, false, image.CurrentScale);
iimage.DrawAsPatternInRect(new RectangleF(0, 0, image.Size.Width, image.Size.Height));
UIImage normalizedImage = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
return normalizedImage;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment