Encode large size image to Base64 String in android
Encode Image
public String BitMapToString(Bitmap bitmap){ ByteArrayOutputStream baos=new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG,100, baos); byte [] b=baos.toByteArray(); String temp=null; try{ System.gc(); temp= Base64.encodeToString(b, Base64.DEFAULT); }catch(Exception e){ e.printStackTrace(); }catch(OutOfMemoryError e){ baos=new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG,50, baos); b=baos.toByteArray(); temp=Base64.encodeToString(b, Base64.DEFAULT); Log.e("EWN", "Out of memory error catched"); } return temp; }
Happy Coding.
Fayetteville NC At Plato's Closet, we buy and sell gently used clothes, shoes, handbags, and accessories for guys and girls in their teens and twenties. We have all the name brands and styles you love at up to 70% less than regular retail prices. We look for brands such as american eagle, free people, nike, urban outfitters, adidas and many many more...
ReplyDelete