using (MemoryStream ms = new MemoryStream())
{
image.CreateOptions = BitmapCreateOptions.None;
image.UriSource = new Uri("/Images/chef.png", UriKind.Relative);
WriteableBitmap LoadedPhoto = new WriteableBitmap(image);
LoadedPhoto.SaveJpeg(ms, LoadedPhoto.PixelWidth, LoadedPhoto.PixelHeight,0,95);
ms.Seek(0, 0);
byte[] data = new byte[ms.Length];
ms.Read(data, 0, data.Length);
ms.Close();
}
我在图像上得到 NullReferenceException,但我的路径也是正确的,图像也存在。
WriteableBitmap LoadedPhoto = new WriteableBitmap(image);
是不是有事。