Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

If you are creating a camera application that will run on a portable device, your application should account for both the physical orientation of the device and the orientation of the shell on the device. The physical orientation of the device relates directly to the orientation of the imaging sensor relative to the physical world. The orientation of the device's shell is the orientation of your application's display environment relative to the physical device.

It is important for your application to be orientation-aware so that it can make the correct compensations both when it displays images to the user, and also when it writes the captured image data to a file. The tables and diagrams later in this topic show how your camera application should handle the various combinations of image, device, and shell orientations.

The following design principles will help you create camera applications that maximize image quality and provide an intuitive experience for the user.

  • Use as many of the pixels on your sensor as possible.

  • Align the output from the viewfinder with the subject. What the user sees in the viewfinder should align with what they see in the real world.

  • Thumbnails should align with the subject, provided device has not moved. Another way to understand this is that the thumbnail should be recorded in the orientation that the user saw the subject.

Implementation Considerations for Camera Applications

When the shell is rotated, the camera application must change the aspect ratio of the preview window by transposing the height and width of the image size reported by the camera driver. For example, if the camera reports a still image resolution of with a 4:3 aspect ration, the camera application must create a preview window that has the same 4:3 aspect ratio when the shell is rotated.

The Microsoft Image Sink Filterhas built-in support for both sensor and shell orientation. If you use this filter, you do not need to make any additions to the filter graph to handle rotation. Third party image sink filters and encoder DMOs must consider the shell rotation when persisting images from the source filter to storage. In particular, the file sink must counter-rotate images. For example, if the shell is rotated +90 degrees (to the right), then the sink filter must rotate the image by -90 (to the left). This guarantees that when the file is viewed, it will exhibit the same image as was seen in the viewfinder at the time of capture.

Implementation Considerations for Drivers

Camera drivers must mark all captured images as pre-rotated and flip the image vertically. This way, if the device is rotated, the display driver will apply the correct rotation when the image is rendered. Camera driver developers must add the BI_SRCPREROTATE flag to the biCompressionfield of the BITMAPINFOHEADERstructure for each media type.

Display drivers must respect the BI_SRCPREROTATE flag on bitmaps. They also must be able to efficiently execute scaling and cropping operations.

Landscape Sensor Orientation

A device with a landscape sensor orientation has its sensor mounted to the device in a way that produces an image in landscape orientation when the device is not physically rotated.   In all the tables below, viewfinder rotation is noted as the amount the shell is rotated relative to the viewfinder

Shell and device are aligned

  Viewfinder = 0º Viewfinder = -90º Viewfinder = +90º

Device orientation

Orientation of image as written to storage

Shell is rotated -90º relative to the device

  Viewfinder = 0º Viewfinder = -90º Viewfinder = +90º

Device orientation

Orientation of image as written to storage

Shell is rotated +90º relative to the device

  Viewfinder = 0º Viewfinder = -90º Viewfinder = +90º

Device orientation

Orientation of image as written to storage

Portrait Sensor Orientation

A device with a portrait sensor orientation has its sensor mounted to the device in a way that produces an image in portrait orientation when the device is not physically rotated.   In all the tables below, viewfinder rotation is noted as the amount the shell is rotated relative to the viewfinder.

Shell and device are aligned

  Viewfinder = 0º Viewfinder = -90º Viewfinder = +90º

Device orientation

Orientation of image as written to storage

Shell is rotated -90º relative to the device

  Viewfinder = 0º Viewfinder = -90º Viewfinder = +90º

Device orientation

Orientation of image as written to storage

Shell is rotated +90º relative to the device

  Viewfinder = 0º Viewfinder = -90º Viewfinder = +90º

Device orientation

Orientation of image as written to storage

See Also

Concepts

Video Capture