Yes, you can send an image without saving it as a file. From simply viewing the code you sent, I have no idea how to send the image, but you are converting a file with the following:
ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] data; if(yourBitmap!=null){ yourBitmap.compress(CompressFormat.PNG, 75, bos); }else if (yourBitmap==null){ Log.w("Image going to server is null","Lost in memory"); } try{ data = bos.toByteArray();
I don’t know if you are sending the image to another user through your application or what, but the way I use it to upload to the server. When you are done with the image, you simply invalidate all this.
bos = null; data = null; yourBitmap = null;
source share