Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Camera-enable Your Applications with BREW's ICamera APIs : Page 2

BREW 2.1's ICamera interface allows you to support still and motion image capture from the image sensor found on many of today's mid- and high-end BREW-enabled wireless handsets. Camera-enable your relevant applications by learning how to configure and use this API.


advertisement
Creating and Configuring the ICamera Interface
Interestingly, creating an instance of ICamera does not require privilege in the application's MIF file; a simple call to ISHELL_CreateInstance suffices:

int Camera_New( CApp* pThis ) { int nErr = 0; nErr = ISHELL_CreateInstance( pThis->a.m_pIShell, AEECLSID_CAMERA, (void**)&pThis->pICamera ); if( SUCCESS == nErr ) { AEESize previewSize = {0}; ICAMERA_RegisterNotify( pThis->pICamera, CameraNotify, pThis ); previewSize.cx = pThis->previewRect.dx; previewSize.cy = pThis->previewRect.dy; ICAMERA_SetDisplaySize( pThis->pICamera, &previewSize ); // Setup extra params ICAMERA_SetParm( pThis->pICamera, CAM_PARM_FLASH, CAM_FLASH_AUTO, 0 ); } return nErr; }

This code first creates an ICamera interface, and then uses it to register the callback function that ICamera will invoke when the camera changes state with ICAMERA_RegisterNotify. Next, it sets the camera viewfinder size—called the preview—based on a rectangle established in the application using ICAMERA_SetDisplaySize. The ICamera interface will attempt to honor the bounds given when creating bitmaps for the preview display, although if it can’t, it may provide smaller bitmaps instead. Finally, the code puts the camera's flash in automatic mode.

While a full list of camera parameters is beyond the scope of this article (the AEECamera.h file and BREW documentation both cover the options in exhaustive detail), you can rest assured that most common camera functions are covered, including details such as encoding quality, the number of frames per second to capture for video, sharpness, zoom, rotation, exposure, white balance, and focus for handsets with variable-focus lenses. In addition, many of the parameters also have attribute setters and getters with obvious names, such as ICAMERA_SetBrightness() or ICAMERA_SetZoom(). Of course, which you use is a matter of style.



Once you have created and configured the camera, it operates as a simple state machine, being in exactly one state (or mode, according to the QUALCOMM documentation) at any given instant. Freshly created and configured, it is in Ready mode, meaning that you can either request it to provide preview bitmaps for you to display on-screen, or capture still or video images. You can always return to Ready mode from any other mode by invoking

ICAMERA_Stop( pThis->pICamera );

As you change modes, ICamera invokes your callback function, indicating the camera's status and mode.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date