新手问题;
我在内存中有一个位图;
Private Bitmap MyPicture;
然后,稍后我会用照相机从imager中填充我的图片。 我需要使用来自apache commons的FTP客户端上传该照片。
fcon.storeFile("filename", new BufferedInputStream(MyPicture.????));
但是Apache需要一个BufferedInputStream。我该如何将内存中的Bitmap转换为内存流?
谢谢大家!
新手问题;
我在内存中有一个位图;
Private Bitmap MyPicture;
然后,稍后我会用照相机从imager中填充我的图片。 我需要使用来自apache commons的FTP客户端上传该照片。
fcon.storeFile("filename", new BufferedInputStream(MyPicture.????));
但是Apache需要一个BufferedInputStream。我该如何将内存中的Bitmap转换为内存流?
谢谢大家!
这就是我在寻找的东西;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
si.Image.compress(CompressFormat.JPEG, 100, stream);
InputStream is = new ByteArrayInputStream(stream.toByteArray());
最后一行是缺失的链接...
将位图转换为字节数组就像这样简单:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
MyPicture.compress(Bitmap.CompressFormat.PNG, 100, baos);
baos.toByteArray();
BufferedInputStream
将字节写入文件。