2012-12-24 54 views
0

我在将现有组件的以下代码片段转换为Silverlight时遇到问题。将Marshal.Copy位图转换为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是所需的图像的宽度和高度。

任何人都可以分享一些想法吗?

回答

0
using (MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length)) 
{ 
    BitmapImage im = new BitmapImage(); 
    im.SetSource(ms); 
    this.imageControl.Source = im; 
}