Forum Xamarin.iOS

picture foggy after resize it

FndFnd TWMember
edited August 2015 in Xamarin.iOS

Hi there,
I tried to resize my picture to match device width,
but my picture is always foggy after resize it,
I tried it in android and it works,
but in iOS it can't work well,
this is my code below:

UIImage image01 = UIImage.FromFile ("history01.png"); image01 = Methods.ResizeImage (image01, (float)View.Frame.Width); UIImageView top = new UIImageView (new CGRect (0, 0, image01.Size.Width, image01.Size.Height)); top.Image = image01;

//Resize Function
public static UIImage ResizeImage (UIImage image, float width)
            float height = (float)image.Size.Height / (float)image.Size.Width * width >= 1 ? (float)image.Size.Height / (float)image.Size.Width * width : 1;
            UIGraphics.BeginImageContext (new SizeF (width, height));
            image.Draw (new RectangleF (0, 0, width, height));
            var resultImage = UIGraphics.GetImageFromCurrentImageContext ();
            UIGraphics.EndImageContext ();
            return resultImage;

Best Answer


Sign In or Register to comment.