后台设置网络资源图片

13年前
  BitmapImage img = new BitmapImage();
                    img.BeginInit();
                    img.UriSource = new Uri(xe.InnerText);
                    img.DownloadCompleted += delegate
                                                 {
                                                     BitmapSource source = new FormatConvertedBitmap(img,
                                                                                                     PixelFormats.
                                                                                                         Pbgra32, null,
                                                                                                     0);
                                                     WriteableBitmap bmp = new WriteableBitmap(source);
                                                     int width = bmp.PixelWidth;
                                                     int height = bmp.PixelHeight;
                                                     int[] pixelData = new int[width*height];
                                                     int widthInBytes = 4*width;
                                                     bmp.CopyPixels(pixelData, widthInBytes, 0);
                                                     for (int i = 0; i < pixelData.Length; i++)
                                                     {
                                                         pixelData[i] ^= 0x00ffffff;
                                                     }
                                                     bmp.WritePixels(new Int32Rect(0, 0, width, height), pixelData,
                                                                     widthInBytes, 0);
                                                     Msg_Img.Source = bmp;
                                                 };
                    img.EndInit();