Hello,
In the above method when I try to resize an image for example of dimensions [1080x2230] to the new dimensions [184x400] it doesn't maintain the aspect ratio there by resulting the output image to be blur.
According to the official documentation of Maui Image, when resizing an image using Bleed mode, the image will maintain its aspect ratio based on the cropping method.
Bleed
, which clips the image so that it fits its target size, while preserving its aspect ratio.
Have you tried the other two Resize modes? Do you see unexpected behavior?
You can use native methods to scale images to target sizes on the Android platform. Please refer to the following code snippet.
#if ANDROID
public static byte[] ResizeImageAndroid (byte[] imageData, float width, float height)
{
// Load the bitmap
Bitmap originalImage = BitmapFactory.DecodeByteArray (imageData, 0, imageData.Length);
Bitmap resizedImage = Bitmap.CreateScaledBitmap(originalImage, (int)width, (int)height, false);
using (MemoryStream ms = new MemoryStream())
{
resizedImage.Compress (Bitmap.CompressFormat.Jpeg, 100, ms);
return ms.ToArray ();
}
}
#endif
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.