BitmapSource to byte []:
private byte[] BitmapSourceToArray(BitmapSource bitmapSource) {
byte [] in BitmapSource:
private BitmapSource BitmapSourceFromArray(byte[] pixels, int width, int height) { WriteableBitmap bitmap = new WriteableBitmap(width, height, 96, 96, PixelFormats.Bgra32, null); bitmap.WritePixels(new Int32Rect(0, 0, width, height), pixels, width * (bitmap.Format.BitsPerPixel / 8), 0); return bitmap; }
source share