Search code examples
androidbitmapbufferedinputstream

android convert bitmap to bufferedinputstream


Newb question;

I've got a bitmap in memory;

Private Bitmap MyPicture;

Then later, I fill that MyPicture from imager from the camera. I need to upload that photo using the FTP client from the apache commons.

fcon.storeFile("filename", new BufferedInputStream(MyPicture.????));

But the apache want a BufferedInputStream. How do I convert the memory Bitmap to a memory stream?

Thanks guys!


Solution

  • This is what I was looking for;

    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    si.Image.compress(CompressFormat.JPEG, 100, stream);
    InputStream is = new ByteArrayInputStream(stream.toByteArray());
    

    The last line was the missing link...