【问题标题】:Converting Marshal.Copy Bitmap to Silverlight Equivalent将 Marshal.Copy 位图转换为等效的 Silverlight
【发布时间】:2012-12-24 14:12:54
【问题描述】:

我在将现有组件的以下代码 sn-p 转换为 Silverlight 时遇到问题。

Bitmap bmp = new Bitmap(width, height);
BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
Marshal.Copy(data, 0, bmpData.Scan0, data.Length);
bmp.UnlockBits(bmpData);

数据为byte[]widthheight 是所需的图像宽度和高度。

谁能分享一些关于这个的想法?

【问题讨论】:

    标签: silverlight writeablebitmap


    【解决方案1】:
    using (MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length))
    {
        BitmapImage im = new BitmapImage();
        im.SetSource(ms);
        this.imageControl.Source = im;
    }
    

    【讨论】:

      猜你喜欢
      • 2019-04-28
      • 2020-04-27
      • 1970-01-01
      • 2016-02-20
      • 2020-07-29
      • 1970-01-01
      • 2021-11-14
      • 2014-02-08
      • 2011-02-10
      相关资源
      最近更新 更多