0

我正在获取图像的解码字符串数据,我想对该数据进行编码并显示在图像视图上。我在位图中得到空值。

这就是我迄今为止所做的。

@SuppressLint("NewApi")
public void show(View view){ 
     byte[] imageBytes = null;
    try {
        imageBytes = imagedata.getBytes("UTF-8");
    break;
// here you could place handling of other clicks if necessary...        
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
        InputStream in = new ByteArrayInputStream(imageBytes);
        Bitmap b = BitmapFactory.decodeStream(in);
         image.setImageBitmap(b);

}
4

1 回答 1

0

要解码图像,请使用以下代码:

byte[] decodedString = Base64.decode(image_path, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length, options);
// options.inJustDecodeBounds = false;
promoIV.setImageBitmap(decodedByte);
于 2013-11-12T07:31:10.707 回答