Image isn't creating using the BitmapFactory.decodeByteArray

前端 未结 2 845
臣服心动
臣服心动 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:31

    remove the below line from your code and try again

    base64data=base64data.substring(1,base64data.length()-1);
    
    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题