由Android Mobile编码的asp.net网络服务中的图像解码问题. [英] Image Decoding problem in asp.net web service which is encoded by Android mobile.

查看:62
本文介绍了由Android Mobile编码的asp.net网络服务中的图像解码问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友
我没有什么问题,我在asp.net中有Web服务.它将以字节为单位解码传入的基数64字符串,并保存为服务器上的图像.当"IPHONE"用户连接Web服务并通过Web服务发送编码数据时,它工作正常.当Android用户点击该服务并通过该服务发送编码的base 64字符串时,Web服务无法正确保存图像.请帮帮我.
我在google上有一半的解决方案.在添加了Android图像编码器算法& 0xFF"之后,我得到了加密的base64字符串.当我的asp.net解码算法运行时,它将一半的图像保存在HDD上.关于字节转换的问题,Android使用Java框架,Java用于将字节从-128保存到127并创建加密的base 64字符串,而加密代码来自asp.net Web服务.它以0到255的字节(无符号)进行解码.因此我遇到了问题.现在的主要问题是,如何更改Java编码代码来编码数据?


Android中的编码方法..

Hi friends ,
I have few problem, I have web service in asp.net . Which is decoding incoming base 64 string in bytes and save as image on server. It''s working fine when "IPHONE" user connect web service and send encoded data over web services. Web services doesn''t save image properly when Android user hit the services and send encoded base 64 string over the service.Please help me.
I got half solution on google . After adding on android Image encoder algorithm "& 0xFF" , then I got encrypted base64 string . When my asp.net decoding algorithm run, it save half image on HDD. Problem regarding to the byte conversion, Android use java frame work , java use to save byte from -128 to 127 and create encrypted base 64 string, while encrypted code comes on asp.net web services. it decoded in byte (unsigned) , in 0 to 255. So that I face the problem. Now main question is that how can i change my java encoding code to encode data?


Encoding Method in Android ..

Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.abx);           
     ByteArrayOutputStream stream = new ByteArrayOutputStream();
                  bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); 
                byte_arr = stream.toByteArray();
 image_str = Base64.encodeBytes(byte_arr);



Asp.net Web服务中的解码方法..



Decoding Method in Asp.net Web Services ..

public string ImageConvert(string _FromString)
    {
        string MailFile = "";
        try
        {

            string s_bitImage = _FromString;
            byte[] bytes = Convert.FromBase64String(s_bitImage);
            System.Drawing.Bitmap image;

            string fileName = "";
            string FolderLocation = System.Web.Configuration.WebConfigurationManager.AppSettings["ImageFolderPath"].ToString();


            using (MemoryStream ms = new MemoryStream(bytes, 0, bytes.Length))
            {
                fileName = Guid.NewGuid().ToString();
                image = (Bitmap)System.Drawing.Bitmap.FromStream(ms);
                
                MailFile = FolderLocation + fileName + ".png";
                image.Save(Server.MapPath(MailFile));

            }
        }
        catch (Exception ex)
        {
            MailFile = ex.Message;
        }


        return MailFile;

    }





谢谢与问候
*********************
KP





Thanks and Regards
*********************
KP

推荐答案

我们不能真正解决上述问题:您需要做一些事情.

1)从iPhone和Android获取原始base64格式的相同图像并将其保存以进行比较.
2)比较两者:有什么区别吗?如果是这样,它们是什么?
3)查看您的代码(我们无权访问),看看它如何处理这种差异.

很抱歉,如果这很笼统,但我们无法读懂您的想法,或者您的服务器硬盘是!

[edit]那3是哪里来的? -OriginalGriff [/edit]
We can''t really solve that problem as stated: you need to do a few things.

1) Get the same image in raw base64 format from the iPhone and the Android and save them for comparison.
2) Compare the two: are there any differences? If so, what are they?
3) Look at your code (which we don''t have any access to to) and see what it does with such differences.

Sorry if this is very general, but we can''t read your mind, or your servers HDD!

[edit]Where did that 3 come from? - OriginalGriff[/edit]


尝试比较Iphone base64字符串和Android Base64字符串.

检查sequences (''+'' = ''%2B'', ''/'' = ''%2F'' and ''='' = ''%3D'')在Android操作系统上的格式是否正确.
Try to compare the Iphone base64 string and Android Base64 string.

check the sequences (''+'' = ''%2B'', ''/'' = ''%2F'' and ''='' = ''%3D'') is formatting correctly from the Android OS.


这篇关于由Android Mobile编码的asp.net网络服务中的图像解码问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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