convert to bitmap android code example
Example 1: 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;
}
}
Example 2: android view to bitmap
public static Bitmap loadBitmapFromView(View v) {
Bitmap b = Bitmap.createBitmap( v.getLayoutParams().width, v.getLayoutParams().height, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
v.layout(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
v.draw(c);
return b;
}