public static byte[] GetBytes(this IImageData imageData) { using (Stream stream = imageData.ReadImage()) { using (MemoryStream memStream = new MemoryStream()) { stream.CopyTo(memStream); return(memStream.ToArray()); } } }