Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将图像从wcf ksoap2传输到android_C#_Java_Android_Wcf_Arraylist - Fatal编程技术网

C# 如何将图像从wcf ksoap2传输到android

C# 如何将图像从wcf ksoap2传输到android,c#,java,android,wcf,arraylist,C#,Java,Android,Wcf,Arraylist,我正在尝试将图像从wcf ksoap2发送到android。 在wcf端,我已将所有图像转换为字节数组,并将它们存储在ArrayList中。 在android端,我从wcf响应填充ArrayList。 现在的问题是字节数组没有正确接收,字节数组没有转换成Image/buffereImage 这是我的密码 byt = new byte[4096]; byt = (byte[]) al.get(5); //Image im; Buffe

我正在尝试将图像从wcf ksoap2发送到android。 在wcf端,我已将所有图像转换为字节数组,并将它们存储在ArrayList中。 在android端,我从wcf响应填充ArrayList。 现在的问题是字节数组没有正确接收,字节数组没有转换成Image/buffereImage

这是我的密码

        byt = new byte[4096];
        byt = (byte[]) al.get(5);
        //Image im;
        BufferedImage bImageFromConvert = null;
        InputStream in = new ByteArrayInputStream(byt);

        try {
            bImageFromConvert = ImageIO.read(in);
            //ImageIO.write(bImageFromConvert, "jpg", new File(
            //      "c:/new-darksouls.jpg"));               

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
}

al是我的ArrayList。

您在android代码端或.net端有问题吗?我在android端有问题。我无法获取它。我想将字节[]转换为Image/BufferedImagetempPath是您的图像路径此函数返回存储字节的imagestring,并将此字符串传递到webservice。我想您可能不明白。我想将图像从wcf传输到android。。不是来自android。我已经在wcf侧将图像转换为字节数组,现在我想在android上接收该字节数组。请检查此。。。位图位图=BitmapFactory.decodeByteArray(bitmapdata,0,bitmapdata.length);返回解码后的位图,如果图像无法解码,则返回null。
private String prepareImage() {
        if (tempPath == null ) {
            return "";
        }

        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
        Bitmap bitmap = BitmapFactory.decodeFile(tempPath, options);
        bitmap = Bitmap.createScaledBitmap(bitmap, 50, 50, true);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        //bitmap.compress(Bitmap.CompressFormat.PNG, 50, baos);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 50, baos);

        byte[] byteArray = baos.toByteArray();

        String imageString = com.size4u.utils.Base64
                .encodeBytes(byteArray);
        bitmap = null;
        System.gc();
        Runtime.getRuntime().gc();
        return imageString;
    }