symba (779893), страница 19
Текст из файла (страница 19)
In this case, only the area of the video within theintersection of the video extent and the window is shown.It is also possible to set the video extent to be a different size to theoriginal video picture. If you set the video extent to be bigger, then youcan choose whether you want to scale the video picture to fit into thevideo extent or whether you leave the video picture at the same size, inwhich case not all of the video extent will be covered. If you set the videoextent to be smaller, then once again you can scale the video picture tofit into the extent or you can leave the video picture at the same sizein which case the part that falls outside the video extent would not bedisplayed.Figure 4.5 shows a larger video extent that is not fully enclosed withinthe window. Here only the parts of the video that appear in the intersection74MULTIMEDIA FRAMEWORK: VIDEOVideo extentWindowDisplayFigure 4.4 Video extent fully within windowVideo extentWindowDisplayFigure 4.5 Large video extent partially outside windowof the window and the video extent are shown.
Note also that the videopicture has not been scaled, so part of the video extent is left unused.Figure 4.6 shows a larger video extent partially outside the window,but in this case the original video picture has been scaled to fit the videoextent. The operation to scale the original video picture into the videoextent is performed first and then the parts of the scaled picture that lieoutside the window are removed.CONTROLLING SCREEN OUTPUT75Video extentWindowDisplayFigure 4.6 Scaling into video extentFor clarity, the figures show the device screen or display with a singlewindow placed on top of it.
It is, however, possible to have more thanone window on the display at the same time.For CVideoPlayerUtility we have seen already how the videoextent is set using a parameter to the NewL() or SetDisplayWindowL() methods. For CVideoPlayerUtility2, the video extent can beset through the AddDisplayWindowL() method, but in addition aspecific SetVideoExtentL() method also exists.void SetVideoExtentL(const RWindowBase& aWindow,const TRect& aVideoExtent);The aWindow parameter allows you to specify which window to applythe video extent to.The SetVideoExtentL() method can only be called after the videoopen operation has completed.4.6.5 Clipping RegionThe clipping region allows you to specify that only a small part of thevideo extent should be shown.
An example of this is shown in Figure 4.7,where a specific clipping region has been applied and only the part ofthe video extent that appears in the clipping region is shown. As before,the mapping of the video picture into the video extent is performed firstand then the clipping region is applied.76MULTIMEDIA FRAMEWORK: VIDEOClipping regionVideo extentWindowDisplayFigure 4.7 Clipping regionFor CVideoPlayerUtility, we have seen already how the clipping rectangle is set using a parameter to the NewL or SetDisplayWindowL() methods.
For CVideoPlayerUtility2 the clipping rectangle can be set through the AddDisplayWindowL() method. There isalso a specific SetWindowClipRectL() method:void SetWindowClipRectL(const RWindowBase& aWindow,const TRect& aWindowClipRect);The aWindow parameter allows you to specify which window toapply the clipping region to. The clipping rectangle must be completelycontained within the specified window.4.6.6 CroppingCropping allows you to specify that only a part of the original video pictureshould be displayed in the video extent. This is shown in Figure 4.8. Onlya small part of the original video picture is selected for display byspecifying a cropping region.
The figure shows that this region has thenbeen scaled to fit into the video extent. You could also just choose tocopy the cropped region into the video extent without scaling it.While cropping and clipping may seem quite similar, the difference isthat the crop is done on the original video whereas the clip is done onthe video extent. You should also remember that the cropped region isdisplayed with its origin set to the top left corner of the video extent. Thereis normally no difference in performance between the two operations, soif you just want to display a non-scaled portion of the video starting atCONTROLLING SCREEN OUTPUTCrop region77Video extentWindowDisplayFigure 4.8 Cropping and scalingits top left corner then you could do this equally well using cropping orclipping.The crop region for a video can be set using the SetCropRegionL()method to specify the crop rectangle:void SetCropRegionL(const TRect& aCropRegion);The crop region applies to the video.
If the video is being displayedin multiple windows, then the results of the crop are seen in all thewindows.The current crop region being used can be retrieved using the GetCropRegionL() method:void GetCropRegionL(TRect& aCropRegion) const;On return, the aCropRegion parameter contains the coordinates ofthe crop rectangle.4.6.7 ScalingThe scale factor of the video can be changed using the SetScaleFactorL() method:void SetScaleFactorL(TReal32 aWidthPercentage, TReal32 aHeightPercentage,TBool aAntiAliasFiltering);78MULTIMEDIA FRAMEWORK: VIDEOYou can specify what percentage to scale the width and height of thevideo. The original image is assumed to have scale percentages of 100,so if you set the scale factor percentage to 50 then you would shrinkthe image to half its original size and a scale factor percentage of 200would double the size of the image.
If you change the width and heightby differing amounts, then you may distort the image.You can also request that anti-alias filtering is used to try to improvethe appearance of the scaled image and remove distortion; however, themajority of video controllers always use anti-alias filtering regardless ofwhat value you set.If the video is being displayed in multiple windows, then the results ofthe scaling are seen in all the windows.You can retrieve the current scale factor information using theGetScaleFactorL() method:void GetScaleFactorL(TReal32& aWidthPercentage,TReal32& aHeightPercentage, TBool& aAntiAliasFiltering) const;CVideoPlayerUtility2 has an extra SetScaleFactorL()method which allows you to specify the scale factors on a per-windowbasis:void SetScaleFactorL(const RWindowBase& aWindow,TReal32 aWidthPercentage, TReal32 aHeightPercentage);The anti-alias filtering option is not offered in this case because thescaling is handled by the graphics composition engine and it always usessome form of anti-aliasing.There is also a GetScaleFactorL() method that works on a perwindow basis:void GetScaleFactorL(const RWindowBase& aWindow,TReal32& aWidthPercentage, TReal32&aHeightPercentage);From Symbian OS v9.4 onwards, some new auto-scaling methods areavailable:void SetAutoScaleL(TAutoScaleType aScaleType);void SetAutoScaleL(TAutoScaleType aScaleType,TInt aHorizPos, TInt aVertPos);CONTROLLING SCREEN OUTPUT79These methods allow you to specify that a video should be automatically scaled to fit the window in which it is being displayed.
Where thevideo is being displayed in multiple windows, the scale options applyto all the windows. The aScaleType parameter specifies the type ofscaling that should be performed:• EAutoScaleNone indicates that no scaling should be performed.• EAutoScaleBestFit indicates that the video should be scaled tofit the extent but the pixel aspect ratio should be maintained,3 and nopart of the video should be clipped in order to fit it into the extent.This may result in areas around the edge of the extent not being filledwith video, in which case they are filled with the background windowcolor.• EAutoScaleClip indicates that the video should be scaled tocompletely fill the extent, while maintaining the pixel aspect ratio.
Ifthe extent and video pixel aspect ratios do not match, this may resultin part of the video being clipped.• EAutoScaleStretch indicates that the video should be scaledto completely fill the extent, without the pixel aspect ratio beingmaintained. If the extent and video pixel aspect ratios do not match,this may result in the video being distorted.The first version of the SetAutoScaleL() method always centersthe video picture within the extent.