In my application, I convert a base64 string to an image. To do this, I initially converted the base 64 file to a byte array and later try to convert it to images. To convert to Pictures, I use the code below
File sdImageMainDirectory = new File("/data/data/com.ayansys.Base64trial"); FileOutputStream fileOutputStream = null; String nameFile="Images"; try { BitmapFactory.Options options=new BitmapFactory.Options(); options.inSampleSize = 5; options.inDither = true; options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap myImage = BitmapFactory.decodeByteArray(imageData, 0, imageData.length); fileOutputStream = new FileOutputStream( sdImageMainDirectory.toString() +"/" + nameFile + ".jpg"); BufferedOutputStream bos = new BufferedOutputStream( fileOutputStream); myImage.compress(CompressFormat.JPEG, quality, bos); bos.flush(); bos.close();
but i get my image as null in
Bitmap myImage = BitmapFactory.decodeByteArray(imageData, 0, imageData.length);
Please let me know your valuable suggestions.
Thanks in advance:)
source share