How many ways to convert bitmap to string and vice-versa?

public String BitMapToString(Bitmap bitmap){ ByteArrayOutputStream baos=new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG,100, baos); byte [] b=baos.toByteArray(); String temp=Base64.encodeToString(b, Base64.DEFAULT); return temp; } Here is the reverse procedure for converting string to bitmap but string should Base64 encoding /** * @param encodedString * @return bitmap (from given string) */ public Bitmap StringToBitMap(String encodedString){ try { byte [] encodeByte=Base64.decode(encodedString,Base64.DEFAULT); Bitmap bitmap=BitmapFactory.decodeByteArray(encodeByte, … Read more

Create Bitmap from a byte array of pixel data

Its safe if you marshal.copy data rather than setting scan0 (directly or via that overload of BitMap()). You don’t want to keep managed objects pinned, this will constrain the garbage collector. If you copy, perfectly safe. The input array is managed and can be moved by the GC, scan0 is an unmanaged pointer that would … Read more