Flipping and Rotating an External Surface

This topic provides an example of flipping and rotating a surface in order to mirror the camera viewfinder during video telephony.

Variant : ScreenPlay. Target audience : Device creators.

When users use the camera at the front of their phone during video telephony, they expect their image to be mirrored like when they look in a mirror. The camera viewfinder renders its content to a graphics surface which is displayed in a window by setting it as the background surface. To mirror the viewfinder content, first flip the surface and then rotate it by 180°.

Figure 1. Mirroring

The following example code assumes that the surface already exists. Call TSurfaceConfiguration::SetFlip() to flip the surface, then call TSurfaceConfiguration::SetOrientation() to rotate the flipped surface by 180°. Finally bind the surface to the window. If necessary, set attributes such as extent to the surface configuration.

      
       
      
      TSurfaceConfiguration config;
RWindow iWindow;

// Set the surface ID.
config.SetSurfaceId(iSurfaceId);

// Get the window size and set the extent.
const TRect windowSize(iWindow->Size());
config.SetExtent(windowSize);

// Set the flipping
config.SetFlip(ETrue);

// Rotate the flipped surface by 180°
config.SetOrientation(CFbsBitGc::EGraphicsOrientationRotated180);

// Bind the surface to the window using the configuration
iWindow.SetBackgroundSurface(config, ETrue);