【发布时间】:2013-05-20 14:02:31
【问题描述】:
我有一个包含迷宫的字符串。
我需要将字符串转换为图像。到目前为止,我尝试了 base64encoder,但似乎 eclispse 不支持它。
有什么简单的解决办法吗?
我已经用谷歌搜索过了。
public String arrayToString(String[][] stringarray)//converts arrays to string(maze array)
{
String str = "\n";
for (int i = 0; i < stringarray.length; i++)
{
for(int j = 0; j<stringarray[i].length;j++)
{
str+=stringarray[i][j];
}
str+="\n";
}
return str;
}
我需要将 str 转换为图像。
public Image Base64ToImage(String base64String)
{
// Convert Base64 String to byte[]
byte[] imageBytes = Convert.FromBase64String(base64String);
MemoryStream ms = new MemoryStream(imageBytes, 0,
imageBytes.length);
// Convert byte[] to Image
ms.Write(imageBytes, 0, imageBytes.length);
Image image = Image.FromStream(ms, true);
return image;
}
我试过了,但 eclipse 不接受内存流..
【问题讨论】:
-
你能分享你的代码吗?
-
你的字符串是base6e编码的字符串?