convert bitmap to image android studio code example

Example 1: get bitmap from imageview

Bitmap bm=((BitmapDrawable)imageView.getDrawable()).getBitmap();

Example 2: convert string to bitmap android

Bitmap b=StringToBitMap(Qrimage);
imgg.setImageBitmap(b);      

public Bitmap StringToBitMap(String image){
           try{
               byte [] encodeByte=Base64.decode(image,Base64.DEFAULT);

               InputStream inputStream  = new ByteArrayInputStream(encodeByte);
               Bitmap bitmap  = BitmapFactory.decodeStream(inputStream);
               return bitmap;
             }catch(Exception e){
               e.getMessage();
              return null;
             }
     }

Tags:

Misc Example