winform的代码怎么样转成wpf的 5C

如图所示,怎样转换成wpf的。picturebox我用的Image,但是whoform中也有image,我用source代替,但是还会报image的错误

  void ShowImage(CaptureInfo info)
        {
            byte[] data = info.Data;

            if (data == null || data.Length == 0)
            {
                return;
            }

            Image image = null;

            using (MemoryStream ms = new MemoryStream())
            {
                try
                {
                    ms.Write(data, 0, data.Length);

                    image = Image.FromStream(ms); 

                }
                catch { }
            }

            int index = this.m_ImageIndex;

            this.ShowCarImageTargetInfo(info, image);

            this.ShowPersonImageTargetInfo(info, image);

            if (index==this.m_ImageIndex)
            {
                PictureBox box = m_ImagesBox[this.m_ImageIndex];

                if (box.Image != null)
                {
                    box.Image.Dispose();
                }

                box.Tag = info.TargetId;

                box.Image = image;
            }

        }

)

2个回答

这鬼才看得清你的问题。

cwt19902010
沧海1梦 你好,请再帮忙看下,作为是图片压缩没传成功
2 年多之前 回复

System.IO.FileStream fs =

new System.IO.FileStream(filepath,

System.IO.FileMode.Open, System.IO.FileAccess.Read);

byte[] buffer = new byte[fs.Length];

fs.Read(buffer, 0, buffer.Length);

fs.Close();

fs.Dispose();

System.IO.MemoryStream ms = new System.IO.MemoryStream(buffer);

BitmapImage bitmapImage = new BitmapImage();

bitmapImage.BeginInit();

bitmapImage.StreamSource = ms;

bitmapImage.EndInit();

img1.Source = bitmapImage;

把image转成bitmapImage

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐