2 cwt19902010 cwt19902010 于 2017.09.13 23:09 提问

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个回答

caozhy
caozhy   Ds   Rxr 2017.09.14 08:30

这鬼才看得清你的问题。

cwt19902010
cwt19902010 你好,请再帮忙看下,作为是图片压缩没传成功
5 个月之前 回复
gjs59408266
gjs59408266   2018.01.04 16:38

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
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!