KnownCameraGeneralProperties.EncodeWithOrientation property

Applies to Windows Phone only

Specifies the orientation, relative to the sensor, that the image is rotated prior to encoding.

Syntax


Public Shared ReadOnly Property EncodeWithOrientation As Guid

Property value

Type: System.Guid [.NET] | Platform::Guid [C++]

The ID of the orientation value.

Remarks

Use this property to specify the orientation of the encoded image. The property value is in units of degrees and must be a multiple of 90 degrees. This property does not modify the image metadata; to specify a rotation value in the image metadata, use the SpecifiedCaptureOrientation property. Setting this property to any value disables automatic orientation. When automatic orientation is disabled, encoding remains at the specified orientation until a new orientation is specified with EncodeWithOrientation.

Note  If you try to set EncodeWithOrientation in the middle of a video recording, it will be letterboxed. The frame size won’t change, but the video will rotate and a "best-fit" will be applied to the original aspect ratio.

This property is common to both the PhotoCaptureDevice and AudioVideoCaptureDevice classes. In the PhotoCaptureDevice class, the GetProperty class gets the current value of the property (of type System.Int32). The SetProperty method sets the property to a new value.

Not all values may be supported by each phone. Use the GetSupportedPropertyRange method to learn more about this property.

The AudioVideoCaptureDevice class also provides the GetProperty, SetProperty, and GetSupportedPropertyRange methods for use with this property.

Examples

The following example shows how to specify the encoding orientation when the phone is in the portrait, portrait-down, landscape, or landscape-right orientation.


// Initialize variables.
int encodedOrientation = 0;
int sensorOrientation = (Int32)this.captureDevice.SensorRotationInDegrees;

switch (this.Orientation)
{
    // Camera hardware shutter button up.
    case PageOrientation.LandscapeLeft:
        encodedOrientation = -90 + sensorOrientation;
        break;
    // Camera hardware shutter button down.
    case PageOrientation.LandscapeRight:
        encodedOrientation = 90 + sensorOrientation;
        break;
    // Camera hardware shutter button right.
    case PageOrientation.PortraitUp:
        encodedOrientation = 0 + sensorOrientation;
        break;
    // Camera hardware shutter button left.
    case PageOrientation.PortraitDown:
        encodedOrientation = 180 + sensorOrientation;
        break;
}
// Apply orientation to image encoding.
this.captureDevice.SetProperty(KnownCameraGeneralProperties.EncodeWithOrientation, encodedOrientation);

Requirements

Minimum supported client

None supported

Minimum supported server

None supported

Minimum supported phone

Windows Phone 8

End of phone support

Windows Phone 8.1 [Windows Phone Silverlight 8.1 apps only]

Namespace

Windows.Phone.Media.Capture
Windows::Phone::Media::Capture [C++]

Metadata

Windows.WinMD

See also

KnownCameraGeneralProperties

 

 

Community Additions

ADD
Show:
© 2014 Microsoft