/// <summary> /// Creates a new <see cref="CapturedImageFrame"/> instance from the <paramref name="stream"/> specified. /// </summary> /// <param name="stream">Captured image stream.</param> /// <param name="encoding">Encoding used to capture the frame <paramref name="stream"/></param> /// <param name="orientation">Camera orientation.</param> /// <param name="cameraType">Camera type.</param> /// <returns>Captured image frame.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="stream"/> is <see langword="null"/>. /// <para>-or-</para> /// <paramref name="encoding"/> is <see langword="null"/>. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="stream"/> cannot be read. /// <para>-or-</para> /// <paramref name="stream"/> is empty. /// </exception> public static CapturedImageFrame CreateFromStream(IRandomAccessStream stream, ImageEncodingProperties encoding, PageOrientation orientation, CameraType cameraType) { if (stream == null) { throw new ArgumentNullException("stream"); } if (!stream.CanRead) { throw new ArgumentException("Stream cannot be read.", "stream"); } if (stream.Size == 0) { throw new ArgumentException("Stream is empty.", "stream"); } if (encoding == null) { throw new ArgumentNullException("encoding"); } return(new CapturedImageFrame { Rotation = OrientationHelper.ConvertOrientationToRotation(orientation, cameraType), Flip = OrientationHelper.ConvertOrientationToFlip(orientation, cameraType), Stream = stream, Height = encoding.Height, Width = encoding.Width }); }
/// <summary> /// Creates a new <see cref="CapturedImageFrame"/> instance from the <paramref name="frame"/> specified. /// </summary> /// <param name="frame">Captured frame.</param> /// <param name="orientation">Camera orientation.</param> /// <param name="cameraType">Camera type.</param> /// <returns>Captured image frame.</returns> /// <exception cref="ArgumentNullException"><paramref name="frame"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentException"> /// <paramref name="frame"/> stream cannot be read. /// <para>-or-</para> /// <paramref name="frame"/> stream is empty. /// </exception> public static CapturedImageFrame CreateFromCapturedFrame(CapturedFrame frame, PageOrientation orientation, CameraType cameraType) { if (frame == null) { throw new ArgumentNullException("frame"); } if (!frame.CanRead) { throw new ArgumentException("Frame stream cannot be read.", "frame"); } if (frame.Size == 0) { throw new ArgumentException("Frame stream is empty.", "frame"); } return(new CapturedImageFrame { Rotation = OrientationHelper.ConvertOrientationToRotation(orientation, cameraType), Flip = OrientationHelper.ConvertOrientationToFlip(orientation, cameraType), Stream = frame, Height = frame.Height, Width = frame.Width }); }