BitmapFactory.de codeByteArray的返回android的空 [英] BitmapFactory.decodeByteArray returns null in android

查看:210
本文介绍了BitmapFactory.de codeByteArray的返回android的空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用我的base64转换成字符串形象方面,我最初转化基地64文件的字节数组,后来我试图转换为图像。
转换成我使用的是低于code图片

In my application I am converting base64 string to image.For that I initially converted base 64 file to byte array and later am trying to convert to images. To convert to Images I am using the below code

    File sdImageMainDirectory = new File("/data/data/com.ayansys.Base64trial");
    FileOutputStream fileOutputStream = null;
    String nameFile="Images";
    try {

        BitmapFactory.Options options=new BitmapFactory.Options();
        options.inSampleSize = 5;
        options.inDither = true; 
        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
        Bitmap myImage = BitmapFactory.decodeByteArray(imageData, 0, imageData.length);


        fileOutputStream = new FileOutputStream(
                sdImageMainDirectory.toString() +"/" + nameFile + ".jpg");


        BufferedOutputStream bos = new BufferedOutputStream(
                fileOutputStream);

        myImage.compress(CompressFormat.JPEG, quality, bos);

        bos.flush();
        bos.close();

但我让我的形象在空

but am getting my image as null at

Bitmap myImage = BitmapFactory.decodeByteArray(imageData, 0, imageData.length);

请让我知道您的宝贵建议。

Please let me know your valuable suggestions.

在此先感谢:)

推荐答案

德codeByteArray的不会转化基地64编码字节数组。你需要先使用Base64编码为字节数组转换

decodeByteArray will not convert base 64 encoding to byte array. You need to use Base64 to byte array converter first

这篇关于BitmapFactory.de codeByteArray的返回android的空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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