我将图像转换为字节的代码,但我在图像框中出现黑屏:
Bitmap bitmap = new Bitmap(100, 100);
MemoryStream MemImage = new MemoryStream();
bitmap.Save(name, ImageFormat.Bmp);
bitmap.Save(MemImage, ImageFormat.Bmp);
byte[] Byte = MemImage.ToArray();
将字节转换为图像:
byte[] data = (byte[])Query.Images;
MemoryStream strm = new MemoryStream();
strm.Write(data, 0, data.Length);
strm.Position = 0;
System.Drawing.Image imgTemp = System.Drawing.Image.FromStream(strm);
BitmapImage bi = new BitmapImage();
bi.BeginInit();
MemoryStream ms = new MemoryStream();
imgTemp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
ms.Seek(0, SeekOrigin.Begin);
bi.StreamSource = ms;
bi.EndInit();
ImageBox.Source = bi;
但是在上面的代码中,一个问题是图像没有显示在图像框中(显示黑屏)请解决这个问题并发给我.....谢谢