The simplest way to resize an UIImage?

前端 未结 30 2635
迷失自我
迷失自我 2020-11-21 22:38

In my iPhone app, I take a picture with the camera, then I want to resize it to 290*390 pixels. I was using this method to resize the image :

UIImage *newI         


        
30条回答
  •  时光说笑
    2020-11-21 23:03

    For my fellow Xamarians, here is a Xamarin.iOS C# version of @Paul Lynch answer.

    private UIImage ResizeImage(UIImage image, CGSize newSize) 
    {
        UIGraphics.BeginImageContextWithOptions(newSize, false, 0.0f);
        image.Draw(new CGRect(0, 0, newSize.Width, newSize.Height));
        UIImage newImage = UIGraphics.GetImageFromCurrentImageContext();
        UIGraphics.EndImageContext();
        return newImage;
    }
    

提交回复
热议问题