如何将二进制数据转换为图像? [英] how to convert binary data to image?

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

问题描述

在我的Andr​​oid应用程序。我得到的二进制code从code JPEG图像如下:

In my android application. I got binary code from a jpeg image from the code as follows.

byte[] val = stream.toByteArray();
          BigInteger bi = new BigInteger(val);
    String s =  bi.toString(2);

此字符串s打印图像的二进制值。
我的问题是如何将这种二进制格式转换为JPEG图像??

This string s prints the binary value of the image. My question is how to convert this binary format into a jpeg image??

推荐答案

我真的不知道你想要什么。

I'm not really sure what you want.


  • 如果你想创建一个位图 -instance直接从您可以使用流 BitmapFactory 和显示屏,位图的ImageView -instance算账:

  • If you want to create a Bitmap-instance directly from the stream you can use BitmapFactory and display that Bitmap in an ImageView-instance afterwards:

Bitmap image = BitmapFactory.decodeStream(stream);
imageView.setImageBitmap(image);


  • 如果您想将字符串转换重新presentation与基数2回二进制数组可以使用的BigInteger 太:

    BigInteger bigInt = new BigInteger(s, 2);
    byte[] binaryData = bigInt.toByteArray();
    


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

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