/// <summary> /// Returns pixels of image as RGBA channels in a stream. (R, G, B, A). 1 byte each. /// Allows writing. /// </summary> /// <param name="bmp">Image to extract pixels from.</param> /// <returns>RGBA channels as stream.</returns> public static MemoryStream GetPixelsAsStream(this BitmapSource bmp) { return(new MemoryStream(bmp.GetPixels(), true)); }