Hello,
On Android, if you need to resize an image, you need to convert it into a bitmap.
Please refer to the following resizer tool code. You can use it directly to resize the image.
public static byte[] ResizeImageOnAndroid (byte[] imageData, float width, float height)
{
// Step 1. Load the bitmap
Bitmap originalImage = BitmapFactory.DecodeByteArray (imageData, 0, imageData.Length);
// Sets the resized size.
Bitmap resizedImage = Bitmap.CreateScaledBitmap(originalImage, (int)width, (int)height, false);
using (MemoryStream ms = new MemoryStream())
{
// Compress the original image to jpeg format with 100 quality.
resizedImage.Compress (Bitmap.CompressFormat.Jpeg, 100, ms);
return ms.ToArray ();
}
}
Best Regards, Wenyan Zhang
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.