Image isn't creating using the BitmapFactory.decodeByteArray

前端 未结 2 857
臣服心动
臣服心动 2020-12-21 01:02

Edit: When I save those bytes in the txt file and when I save it as png file , it shows the image, but it is not working here why...?

I am using this code to create

2条回答
  •  暖寄归人
    2020-12-21 01:46

    Try this code while getting bitmap from different resources...

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeByteArray(base64converted,0,base64converted.length,options);
    
    // Calculate inSampleSize
    options.inSampleSize = calculateInSampleSize(options, 500, 500);
    // Decode bitmap with inSampleSize set
    options.inJustDecodeBounds = false;
    Bitmap bmp1=BitmapFactory.decodeByteArray(base64converted,0,base64converted.length,options);
    

    follow the tutorial on this link Efficient way to show bitmaps

提交回复
热议问题