android - Unable to convert image bitmap to byteArray -
i using following code encode image bitmap byte[] , string @ time of encoding byte[] says unable encode..
bitmap bm = bitmapfactory.decodefile(path); bytearrayoutputstream stream = new bytearrayoutputstream(); (bm).compress(bitmap.compressformat.jpeg, 100, stream); bm.recycle(); byte[] byteformat = stream.tobytearray(); string encodedimage = base64.encodetostring(byteformat, base64.no_wrap);
the app working fine, stuck here. suggest issues.
public static byte[] bitmaptobytearray(bitmap bitmap){ bytearrayoutputstream stream = new bytearrayoutputstream(); bitmap.compress(bitmap.compressformat.png, 100, stream); byte[] bytearray = stream.tobytearray(); bitmap.recycle(); return bytearray; }
Comments
Post a Comment