How Do I convert BitmapSource to MemoryStream. Though I tried some code:
private Stream StreamFromBitmapSource(BitmapSource writeBmp) { Stream bmp; using (bmp = new MemoryStream()) { BitmapEncoder enc = new BmpBitmapEncoder(); enc.Frames.Add(BitmapFrame.Create(writeBmp)); enc.Save(bmp); } return bmp; } It doesn't give any error but after putting debugging point it is showing some exceptions which are listed below.
Capacity: 'printStream.Capacity' threw an exception of type 'System.ObjectDisposedException' Length: 'printStream.Length' threw an exception of type 'System.ObjectDisposedException' Position: 'printStream.Position' threw an exception of type 'System.ObjectDisposedException'
face recognition API.So, I'm returning my result to aStreamwhich myface recognition APIwill utilize.