Get Bytes From BitmapSource
/* License: Microsoft Public License (Ms-PL) http://c4fdevkit.codeplex.com/license C4F Developer Kit */ using System; using System.IO; using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Windows.Media.Imaging; public class MainClass{ static byte[] GetBytesFromBitmapSource(BitmapSource bmp) { int width = bmp.PixelWidth; int height = bmp.PixelHeight; int stride = width * ((bmp.Format.BitsPerPixel + 7) / 8); byte[] pixels = new byte[height * stride]; bmp.CopyPixels(pixels, stride, 0); return pixels; } }