首页新闻找找看学习计划

江湖救急!!Winform的PictureBox控件无法显示图片流?

0
悬赏园豆:10 [已关闭问题] 关闭于 2016-12-09 16:29
    if (imgS != "")
    {
                pictureBox1.Image = Image.FromStream(StringToStream(imgS));
                pictureBox1.Visible = true; 
             }

ImgS值:

"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAABGCAYAAABL0p+yAAAa1UlEQVR42u2daXhU5dnHwbVqtS61Wrto1drWWrTavbUudV8q1qVKpe5L0bqgUBHFHRQQRVZBwpYQEkhIgGxkI3sySWYmsy9ZQNG2V6937XW9X+93fgef4ZkzZ5LZEhLIh+eCzJxznu2+//f/Xp4zE3p7e0W1kD8s+t/jbfQ2n9Mj7k6n8f+VSzZJ7vrSgzaWkNsdaZ607p2g/+G2haR9W3B8g8dY67Q5JO8gCmDY75egw5m5ANIC7nEUTLuFw7JnU+iwm3c4Mu9gZ1d2BDDZ5uwsl2DAc9gtdtkn/VK3py/h9/teDkh/7WEohKFwpIVGTgA9Pc3SUrPU8rtKb5nku3PH/KJ6vX7ZWdIY81n13j7Z+cnAONpnqU3IBvxafb7G9ZF4Q97sEG5fIGE/6Y7PkkxbaPAr09dIwD92eHHeip6IZUp+zkV7yiXcGx69AvhZqEA+CVeJ21kS2YjOYR/Qnl639Pf6Yj57adY6eW3OxpSFcNP8Etn41takrv04f73kbyvMePwN7n4pdRw8hCzMcUneyp54auCokT0eW9znH366Tt7at3TYx1VXtUcc3X1pIGBk0/eGayQUdEtt+fVDdtRlD8rtD9dnMNig/MdARdznPV6vTFm8JLXwQDAxJ/E7fGkj5WCtJ9Ar7zTuG3XI2Bf0yf/senfoa4N+6fV0Z73/Hmef3HzpvzM3waGQb8hr6ht9Ulk7uh2UbY8VSuv6pjFjWjtq54qzPU+m/7NGVu3rGL74YoddBjY8I/01OcPkMWeZA4634W32Bqe8edFiA6GNFuFr7r7h46RBt1eaF2+SPnuD5ffuCMJ3eUeRE2LVmtqapcftsvzOUbtTAi7nYSlMdcVzpK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sQ1JtH+Z5Ru3YkmlLLtqVnXKsQ7k93zxDls6pSOqnv0a6Ld0Un4U584yaUTnWT3o5ihnOGtoeVr+UdO1NDeJ0jQ2kaWsLjAgqVjs2R/upf3mDhAKDV4X/vZdKqMChwwFHsn1Q8Km4vOM/46W3d6vvlRb3/jq+9tVl4m3b79FeVfGitPq6D30nJA7Ki3sk3BUYtud/VrRc9u4uHXWCsHa+XapLPAet/5nPPi5VlQeySc2+Lqn3dhyGAri8U8Lz2oft+QNdzdLnHX3hid0VPmmp9WXteR5nWD7//B3Zty+50362jjbZvm3kf9w6KQH0d7aJq6r0IIcuwmPaUxzpVl8aklnXe2RgIP7EYV/1Ntm76Dnre3190uvvG31xwK4NyyTk9x3URX3hilzxeYKjaqMLq/PEHzwQy+sfcFl6iQejBQb5we+B0nURQUuwnzn/Lb2BwyQQPdZbzs6V0tx14Oex9uztkv5+z9ifmwUKlnU3iN03eOamoNkjnSmARMYCuGvzVlk5fXZGz2ioaZV1ywpTLn71+tzjSjCCzen3SGHH4CffmpwBmVPSPbIIWJlbIK7uzCplVi7MFUd38s6B3++VxStekh6XfVw4DrVyrOFsjW31YrMfcO9rd4WkelfqP5taVrJKija/P76JI9T2te2TT23x74/pbAuJJ4Pg/v8D/6zfYcMEs7cAAAAASUVORK5CYII="
复制代码
private Stream StringToStream(string ss)
        {
            byte[] bytes = GetBytes(ss);
            Stream stream = new MemoryStream(bytes);
            return stream;
        }

        static byte[] GetBytes(string str)
        {
            byte[] bytes = new byte[str.Length * sizeof(char)];
            System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
            return bytes;
        }

        static string GetString(byte[] bytes)
        {
            char[] chars = new char[bytes.Length / sizeof(char)];
            System.Buffer.BlockCopy(bytes, 0, chars, 0, bytes.Length);
            return new string(chars);
        }
复制代码

为啥无法显示呢?  试了很多次了

王庆东mas的主页 王庆东mas | 初学一级 | 园豆:4
提问于:2016-12-09 16:19
< >
分享
所有回答(1)
0

解决了。

主要是以下2点:

1.从base64字符串转到byte[]

byte[] buff = Convert.FromBase64String(input);

2.

上面的图片流(base64字符串)不应该包含“data:image/png;base64,”

王庆东mas | 园豆:4 (初学一级) | 2016-12-09 16:29
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册