Take image from gallery and convert to base64 issue

前端 未结 4 1438
醉话见心
醉话见心 2021-01-03 14:13

sorry for asking silly question.but it solved yet my me.please help i had tried all codes on stackoverflow and follow other tutorial but it wont help at all.i am taking imag

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-03 14:54

    Try this...

    public String getStringImage(Bitmap bmp){
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            bmp.compress(Bitmap.CompressFormat.JPEG, 100, baos);
            byte[] imageBytes = baos.toByteArray();
            String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);
            return encodedImage;
        }
    

提交回复
热议问题