Android的转换位图的BufferedInputStream位图、Android、BufferedInputStream

2023-09-07 00:20:09 作者:“旧城半夏°

福利局问题;

我有在内存中的位图;

I've got a bitmap in memory;

Private Bitmap MyPicture;

后来的后来,我填从相机成像的MyPicture。我需要使用FTP客户端从Apache公地,上载照片。

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.????));

但阿帕奇希望的BufferedInputStream。如何转换的内存位图到内存流?

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

谢谢你们!

推荐答案

这就是我一直在寻找;

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...