pictureBox绑定Base64字符串

if (!string.IsNullOrEmpty(imageCode))
            {
                byte[] bytes = Convert.FromBase64String(imageCode);
                MemoryStream s = new MemoryStream(bytes, true);
                s.Write(bytes, 0, bytes.Length);

                Image a = new Bitmap(s);

                Bitmap bit = new Bitmap(this.pictureBox.Width, this.pictureBox.Height);
                Graphics g = Graphics.FromImage(bit);//从指定的 Image 创建新的 Graphics(绘图)。
                g.DrawImage(a, new Rectangle(0, 0, bit.Width, bit.Height), new Rectangle(0, 0, a.Width, a.Height), GraphicsUnit.Pixel);
                this.pictureBox.Image = bit;
            }

猜你喜欢

转载自www.cnblogs.com/XuPengLB/p/9365972.html