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();
}
I am getting NullReferenceException at image, but my path is also correct and image also exists.
WriteableBitmap LoadedPhoto = new WriteableBitmap(image);
Is anything goes wrong.
Please Refer the solution. which shows the solution to converting the bitmapimages to byte array.
I hope you will understand.. conversion of bitmapimage to byte array
Refer this link..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.