Search code examples
javaandroidimagebitmaprescale

Enlarging a Bitmap


I would like to resize an image (Bitmap) with a minimum width and height and keep the ratio.

For now I tryed some methods but I didnt get a correct result.

The closest way was with this method:

Bitmap.createScaledBitmap(bitmapToScale, newWidth, newHeight, false);

and there is the result:

croped image

croped image

The image is indeed resized but only the last column and row are dulicated to the end (right and bottom)

Do anyone as a good method to resize an image on Android ?

(PS: I can't use xml scale option cose I have to transform the image after the crop and neither Glide or picasso)


Solution

  • Bitmap.createScaledBitmap is the correct way to scale a bitmap. The result you are getting might be the result of improper implementation while displaying it. Such result usually occurs if you are using BitmapShader.