android - why when save image in storage is black? -
i use code set bitmap imageview , image form imageview , save in storage when save it, image black! please solve problem!
bitmap bitmap = ink.getbitmap(); img_signature.setimagebitmap(bitmap); bytearrayoutputstream stream = new bytearrayoutputstream(); bitmap.compress(bitmap.compressformat.jpeg, 50, stream); byte[] bytearray = stream.tobytearray(); encodedstring = base64.encodetostring(bytearray, 0); createdirectoryandsavefile(bitmap,"signature.jpg");
and method save image :
private void createdirectoryandsavefile(bitmap imagetosave, string filename) { file direct = new file(environment.getexternalstoragedirectory().getabsolutepath() + "/delivery/"); if (!direct.exists()) { direct.mkdirs(); } file file = new file(direct, filename); if (file.exists()) file.delete(); try { fileoutputstream out = new fileoutputstream(file); imagetosave.compress(bitmap.compressformat.jpeg, 100, out); out.flush(); out.close(); } catch (exception e) { e.printstacktrace(); }
}
wiki
Comments
Post a Comment