pictureBox绑定Base64字符串

时间:2022-05-12 03:51:12
if (!string.IsNullOrEmpty(imageCode))
{
byte[] bytes = Convert.FromBase64String(imageCode);
MemoryStream s = new MemoryStream(bytes, true);
s.Write(bytes, , 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(, , bit.Width, bit.Height), new Rectangle(, , a.Width, a.Height), GraphicsUnit.Pixel);
this.pictureBox.Image = bit;
}