symba (Symbian Books), страница 13
Описание файла
Файл "symba" внутри архива находится в папке "Symbian Books". PDF-файл из архива "Symbian Books", который расположен в категории "". Всё это находится в предмете "основы автоматизированного проектирования (оап)" из 3 семестр, которые можно найти в файловом архиве МГТУ им. Н.Э.Баумана. Не смотря на прямую связь этого архива с МГТУ им. Н.Э.Баумана, его также можно найти и в других разделах. Архив можно найти в разделе "книги и методические указания", в предмете "основы автоматизированного производства (оап)" в общих файлах.
Просмотр PDF-файла онлайн
Текст 13 страницы из PDF
If morethan one client is requesting control, then a priority calculation is usedto determine which client should have it. Higher priority clients takeownership from lower priority clients when they contend for use of thecamera.There are two parts that make up a client’s priority value:• Clients may declare themselves to have a priority from −100 to 100.The default priority is zero.• Clients with MultimediaDD capability take priority ahead of clientswithout that capability, regardless of the declared priority values.A camera implementation may use additional prioritization decisions,such as prioritizing a particular process ID.
However the API does notassume any camera policy for this, as it is implementation-specific.The CCamera::Reserve() call is unsuccessful if a higher priorityclient is already using the camera: the MCameraObserver2::HandleEvent() callback returns an error.If a client is superseded by another, it receives a MCameraObserver2::HandleEvent() notification that the camera is no longer available. It should expect no further callbacks for outstanding capturerequests or notifications for pending custom extended operations (histograms, snapshots, etc.) and further attempts to use the camera withouta successful CCamera::Reserve() call will fail.3.3.1 Power ControlOnce a camera object is available, the client application needs to switchon the camera power, using CCamera::PowerOn(). The callbackinterface is notified when power on is complete.
Once the power-oncallback is received, the camera is ready to be used and the client canstart setting up the viewfinder or capturing images.As continuous camera use can drain the battery, the camera should beswitched off whenever it is not in use, by calling CCamera::PowerOff().40THE ONBOARD CAMERAIn addition, the viewfinder should have a timeout since this, in particular,will drain the battery.void CCameraAppUi::HandleCommandL(TInt aCommand){switch (aCommand){// An example AppUI command to start the camera examplecase ECommandCameraOn:{// Reserve the cameraiCamera->Reserve();}break;}}//Handle event method from MCameraObserver2void CCameraAppUi::HandleEvent(const TECAMEvent& aEvent){if (aEvent.iEventType == KUidECamEventReserveComplete){if (aEvent.iErrorCode == KErrNone){iCamera->PowerOn();}else//report error to user}else if (aEvent.iEventType == KUidECamEventPowerOnComplete){if (aEvent.iErrorCode == KErrNone){// camera now ready for use}else//report error to user}}// from MCameraObservervoid CCameraDemoAppUi::ReserveComplete(TInt aError){if (aError == KErrNone){iCamera->PowerOn();}else{// handle error}}void CCameraDemoAppUi::PowerOnComplete(TInt aError){if (aError == KErrNone){// camera now ready for use}}CAMERA CONTROL413.3.2 Basic Image SettingsThe CCamera class allows access to the camera’s settings.
It providesfunctions that allow you to select the image format and to alter brightness,contrast, zoom, exposure, flash and white balance levels of the cameraimage. Before using such functions though, you should test that thecamera supports what you want.
To do this, get a TCameraInfo objectusing the CameraInfo() function. The object’s iOptionsSupportedmember is a bitfield of flags that describe which options are supportedby the camera.Image FormatBefore a client application captures still or video images it can first specifythe required image format. There may be complicated dependenciesbetween frame sizes and formats, so the required format must be specifiedas follows:1. Select the format from those available from either the TCameraInfo::iImageFormatsSupported or TCameraInfo::iVideoFrameFormatsSupported bitfields, for still or video imagesrespectively.2.
Select the required size using either CCamera::EnumerateCaptureSizes() or CCamera::EnumerateVideoFrameSizes()for still or video images respectively. Note that not all possible sizesare guaranteed to be supported for any given format. Unsupportedsizes are returned as (0,0).3. For video capture, select the frame rate using CCamera::EnumerateVideoFrameRates(). Again, not all rates are guaranteed tobe supported, as dependencies may exist in the camera between theformat, size, exposure mode and rate.BrightnessTo alter the camera image brightness:1. Check if brightness control is supported, by testing if the TCameraInfo::EBrightnessSupported flag is set in the options.2.
Set the brightness using CCamera::SetBrightnessL().3. The brightness should be in the range −100 to +100. To set thebrightness automatically, use the flag CCamera::EBrightnessAuto.TBool brightnessSupported = info.iOptionsSupported &TCameraInfo::EBrightnessSupported;42THE ONBOARD CAMERAif (brightnessSupported){iCamera->SetBrightnessL(CCamera::EBrightnessAuto);}ContrastTo alter the camera image contrast:1.Check if contrast control is supported, by testing if the TCameraInfo::EContrastSupported flag is set in the options.2.Set the contrast using CCamera::SetContrastL().
The contrast should be in the range −100 to +100. To set the contrastautomatically, use the flag CCamera::EContrastAuto.TBool contrastSupported = info.iOptionsSupported &TCameraInfo::EContrastSupported;if (contrastSupported){iCamera->SetContrastL(CCamera::EContrastAuto);}ZoomTo alter the camera’s zoom level:1.Test if zoom is supported, and for what range of values, by readingthe minimum and maximum zoom values from the data membersin TCameraInfo.
A value of zero means zoom is not supported.A step of one in the zoom value corresponds to the smallest zoomchange available. The camera zoom increases linearly with the zoomvalue until the maximum zoom is reached. A separate set of valuesis available for (optical) zoom and for digital zoom. TCameraInfoalso has members iMinZoomFactor and iMaxZoomFactor thatcontain the actual zoom factor when at minimum (non-digital only)and maximum zoom.2.Set the zoom using CCamera::SetDigitalZoomFactorL() orCCamera::SetZoomFactorL().TCameraInfo info;iCamera->CameraInfo(info);// setup optical zoomTInt minZoom = info.iMinZoom;TInt maxZoom = info.iMaxZoom;DISPLAYING THE VIEWFINDER43if (minZoom != 0) // if it is supported{// set a value from minZoom to maxZoomiCamera->SetZoomFactorL(maxZoom);}// set up digital zoomTInt maxDigitalZoom = info.iMaxDigitalZoom;if (maxDigitalZoom > 0) // if it is supported{// set a value from 0 to maxDigitalZoomiCamera->SetDigitalZoomFactorL(maxDigitalZoom);}White BalanceWhite balance presets are given by the CCamera::TWhiteBalanceenum.
Supported white balance options are given in TCameraInfo::iWhiteBalanceOptionsSupported. EWBAuto is the default and isalways supported. To alter the white balance to compensate for tungstenlighting, use:iCamera->SetWhiteBalanceL(CCamera::EWBTungsten);ExposureExposure presets are given by the CCamera::TExposure enum. Supported exposure presets are given in TCameraInfo::iExposureModesSupported.
EExposureAuto is the default and is always supported. To alter the exposure for nighttime shots, call:iCamera->SetExposureL(CCamera::EExposureNight);FlashFlash presets are given by the CCamera::TFlash enum. Supportedflash settings are given in TCameraInfo::iFlashModesSupported.EFlashNone is the default. To alter the flash mode, use:iCamera->SetFlashL(CCamera::EFlashAuto);3.4 Displaying the ViewfinderAfter we have successfully powered on the camera hardware, we candisplay a viewfinder.44THE ONBOARD CAMERAThe viewfinder can, if the camera implementation supports it, transferframes from the camera directly to the display memory at a location of theclient’s choosing. Alternatively, if supported, the application developersmay implement a viewfinder function, in which case the client is passedthe viewfinder image as a bitmap at regular intervals.The option to use is determined by the capabilities of the camera.The iOptions member of TCameraInfo may have one or both of thefollowing two bits set:• EViewFinderBitmapSupported – we have to render the viewfinder ourselves using bitmaps supplied by the camera.• EViewFinderDirectSupported – the frames are transferred fromthe camera directly to the display memory at the location the clientchooses.It is possible that neither method is supported, so you should alwayscheck which method is supported before attempting to render a viewfinder.You can specify the portion of the screen to which viewfinder datais to be transferred.
This is specified in screen co-ordinates and may bemodified if, for example, the camera requires the destination to have acertain byte alignment. The size of image returned by the viewfinder maynot be the exact size requested if this conflicts with the requirement forthe viewfinder to show the unclipped view in the ratio required for videocapture. In this case, the camera returns the best match.3.4.1 Direct Screen Access ViewfinderRendering of a direct screen viewfinder, where the frames are transferredfrom the camera directly to the display memory at a location of theclient’s choosing, is the most efficient method. The rendering is doneby the camera subsystem and is usually optimized to make use of anyhardware acceleration present.
To draw a direct screen access viewfinder,we use the following method:virtual void StartViewFinderDirectL(RWsSession& aWs,CWsScreenDevice& aScreenDevice,RWindowBase& aWindow,TRect& aScreenRect);The first three parameters can be retrieved from an application GUIenvironment; aScreenRect is the rectangle, relative to the physicalscreen, in which the viewfinder is to be rendered. Once a successfulcall has been made to StartViewFinderDirectL(), the viewfinderis visible to the user.