Java android SkImageDecoder::工厂返回空值(位图)

Java android SkImageDecoder::工厂返回空值(位图),java,android,bitmapfactory,Java,Android,Bitmapfactory,我正在向服务器发送图像。发送5或6个图像后,我将随机收到此错误。我不知道位图为什么返回null。因为我是Android的初学者,所以我对Android编程不太了解。谁能帮帮我吗 这是我的密码 protected String doInBackground(String... path) { String outPut = null; for (String sdPath:path) { Bitmap bitmapOrg = BitmapFactory.dec

我正在向服务器发送图像。发送5或6个图像后,我将随机收到此错误。我不知道位图为什么返回null。因为我是Android的初学者,所以我对Android编程不太了解。谁能帮帮我吗

这是我的密码

protected String doInBackground(String... path) {

    String outPut = null;

    for (String sdPath:path) {

        Bitmap bitmapOrg = BitmapFactory.decodeFile(sdPath);
        ByteArrayOutputStream bao = new ByteArrayOutputStream();

        //Resize the image
        double width = bitmapOrg.getWidth();
        double height = bitmapOrg.getHeight();
        double ratio = 400/width;
        int newheight = (int)(ratio*height);


        bitmapOrg = Bitmap.createScaledBitmap(bitmapOrg, 400, newheight, true);

        //Here you can define .PNG as well
        bitmapOrg.compress(Bitmap.CompressFormat.JPEG, 95, bao);
        byte[] ba = bao.toByteArray();
        String ba1 = Base64.encodeToString(ba, 0);

        //System.out.println("uploading image now ——–" + ba1);

        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("image", ba1));

        try {
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("http");
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();                

            // print responce
            outPut = EntityUtils.toString(entity);
            Log.i("GET RESPONSE—-", outPut);

            //is = entity.getContent();
            Log.e("log_tag ******", "good connection");

            bitmapOrg.recycle();

        } catch (Exception e) {
            Log.e("log_tag ******", "Error in http connection " + e.toString());
        }
    }
    return outPut;
}
受保护的字符串doInBackground(字符串…路径){
字符串输出=null;
for(字符串sdPath:path){
位图bitmapOrg=BitmapFactory.decodeFile(sdPath);
ByteArrayOutputStream bao=新建ByteArrayOutputStream();
//调整图像大小
double-width=bitmapOrg.getWidth();
double height=bitmapOrg.getHeight();
双倍比=400/宽;
int newheight=(int)(比率*高度);
bitmapOrg=Bitmap.createScaledBitmap(bitmapOrg,400,newheight,true);
//在这里您还可以定义.PNG
compress(Bitmap.CompressFormat.JPEG,95,bao);
字节[]ba=bao.toByteArray();
字符串ba1=Base64.encodeToString(ba,0);
//System.out.println(“正在上载图像---”+ba1);
ArrayList nameValuePairs=新的ArrayList();
添加(新的BasicNameValuePair(“图像”,ba1));
试一试{
HttpClient HttpClient=新的DefaultHttpClient();
HttpPost HttpPost=新的HttpPost(“http”);
setEntity(新的UrlEncodedFormEntity(nameValuePairs));
HttpResponse response=httpclient.execute(httppost);
HttpEntity=response.getEntity();
//打印响应
输出=EntityUtils.toString(实体);
i(“获取响应--”,输出);
//is=entity.getContent();
Log.e(“Log_tag*******”,“良好连接”);
bitmapporg.recycle();
}捕获(例外e){
Log.e(“Log_标记*******,“http连接错误”+e.toString());
}
}
返回输出;
}