0
從我的Android應用我發送圖像到C#服務器從服務器端轉換爲Base64發送圖像作爲Base64.encodeToString從機器人到C#如何獲取圖像
@Override
public void onPictureTaken(byte[] data, Camera camera)
{
String image = Base64.encodeToString(data, Base64.DEFAULT);
sendtoserver(image);
}
我收到了字符串,但不知道如何將它轉換和保存it.For幫助我得到這個字符串告訴我怎麼把它轉換並將其保存在C#
/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ
是的,我曾試過。當我試圖轉換該字符串(給出了波紋管)時,轉換時出現錯誤 ** System.FormatException:輸入不是有效的Base-64字符串,因爲它包含非基本64字符,多於兩個填充字符或填充字符中的非空白字符。 at System.Convert.FromBase64String(String s) at AndroidService..ctor()in d:\ ABCDED \ AndroidService \ App_Code \ AndroidService.cs:line 24 ** – Anirban 2013-03-22 05:58:43
我也試過,得到一個Exception:Invalid length for一個Base-64字符數組。您能否提供您首先編碼的圖像,以便我們檢查base64編碼是否正確? – 2013-03-22 06:05:40
轉換代碼**/9J/4RngRXhpZgAASUkqAAgAAAAMAAABBAABAAAAAAUAAAEBBAABAAAAwAMAAA8BAgAIAAAAngAA ABABAgAJAAAApgAAABIBAwABAAAAAQAAABoBBQABAAAA0AAAABsBBQABAAAA2AAAACgBAwABAAAA AgAAADEBAgAMAAAAsAAAADIBAgAUAAAAvAAAABMCAwABAA ** ImageLink的HTTP://i50.tinypic.com/2ujox9z.jpg – Anirban 2013-03-22 06:17:41