DEV Community

SafetyChain Software
SafetyChain Software

Posted on

Xamarin.iOS : Image resizes/Scales to blank

When we click image from camera to upload we scale down the image to 800*600 size but after uploading to server image is showing gray/currpeted

Image description

We are using below code in Xamarin.iOS to Scale the image but after uploading image to server its showing gray/blank image
`var sourceSize = sourceImage.Size;
var maxResizeFactor = Math.Min(newSize.Width / sourceSize.Width, newSize.Height / sourceSize.Height);

    if (maxResizeFactor > 1) return sourceImage;
    var width = maxResizeFactor * sourceSize.Width;
    var height = maxResizeFactor * sourceSize.Height;
    UIGraphics.BeginImageContext(new CGSize(width, height));
    sourceImage.Draw(new CGRect(0, 0, width, height));
    var resultImage = UIGraphics.GetImageFromCurrentImageContext();
    UIGraphics.EndImageContext();
    return resultImage;`
Enter fullscreen mode Exit fullscreen mode

Please help us to resolve this issue

Top comments (0)