如何在android中将图像转换为字节? [英] how to convert image into byte in android?

查看:122
本文介绍了如何在android中将图像转换为字节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在android中将图像转换为字节,并将该字节传递给Web服务

How to convert image into byte in android and that byte pass to web services

推荐答案





我假设你的意思是字节数组而不是字节,因为将图像转换为字节没有多大意义。



看看这里:

http://stackoverflow.com/a/10514374 [ ^ ]

Hi,

I assume you mean a byte array and not a byte, because converting an image to a byte does not make much sense.

Have a look here:
http://stackoverflow.com/a/10514374[^]

试试这个:

Try this:

// convert from bitmap to byte array
public byte[] getBytesFromBitmap(Bitmap bitmap) {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    bitmap.compress(CompressFormat.JPEG, 70, stream);
    return stream.toByteArray();
}


ProgramFOX已经为您提供了一个很好的解决方案。我想扩展它。请参阅上面这两个链接:

将图像转换为字节数组 [ ^ ]

将图像转换为ByteArray [ ^ ]
ProgramFOX already gave you a good solution. I want to extend that. See these 2 links with the above one:
Convert image to byte array[^]
Convert Image into ByteArray [^]


会员8825505.

对不起不要叫你的名字。



这是你的答案。



http://forums.xamarin.com/discussion/5950/how-to-convert-from-bitmap -to-byte-without-bitmap-compress [ ^ ]

http://stackoverflow.com/questions/10191871/converting-bitmap-to-bytearray-android [ ^ ]



我希望它可能是帮助你。
Hi, Member 8825505.
I'm sorry not call your name.

Here is your answer.

http://forums.xamarin.com/discussion/5950/how-to-convert-from-bitmap-to-byte-without-bitmap-compress[^]
http://stackoverflow.com/questions/10191871/converting-bitmap-to-bytearray-android[^]

I hope it could be help you.


这篇关于如何在android中将图像转换为字节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆