How to Resize a Bitmap in Android?

后端 未结 16 2433
有刺的猬
有刺的猬 2020-11-22 03:13

I have a bitmap taken of a Base64 String from my remote database, (encodedImage is the string representing the image with Base64):

profileImage          


        
16条回答
  •  面向向阳花
    2020-11-22 03:47

    Change:

    profileImage.setImageBitmap(
        BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length)
    

    To:

    Bitmap b = BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length)
    profileImage.setImageBitmap(Bitmap.createScaledBitmap(b, 120, 120, false));
    

提交回复
热议问题