Resources | Resources |



Previewing a Snapshot or Movie


This topic describes how to preview a snapshot or movie frame on the device screen.


To display an image:

  1. Set the image size.

    The image size is the resolution of the image captured.

  2. Set the display size.

    The display size is the size of the frame returned to the application.

  3. Set the preview type.
  4. Set the encoding information.
  5. Set the output parameters.
  6. Verify the camera is in the Ready mode.
  7. Change the mode to Preview.
  8. In the callback function, display the frame for every frame notification.
  9. When you are done viewing the frame, all ICAMERA_Stop().

    This returns the ICamera object to the ready mode.

Event handling

The callback function receives the AEECameraNotify structure as a parameter. The callback function checks the nStatus field for CAM_STATUS_FRAME and CAM_STATUS_DONE.

When the nStatus field is CAM_STATUS_FRAME, a new frame is available to be displayed. The application calls ICamera_GetFrame() to retrieve a pointer to the raw frame. The orientation (portrait vs landscape) can be determined by calling IBitmap_GetInfo(). The application then calls IDISPLAY_BitBlt () to prompt the camera to process the image and copy the processed frame to a display buffer. To display the new frame, call IDISPLAY_Update( ).

When the nStatus field is CAM_STATUS_DONE, ICamera has completed the command in the nCmd field.

After the notification of completion of the command CAM_CMD_START, the application is in the ready state and can save a snapshot or a movie to a file.

Example - Show a frame

Set the image size of the picture or movie.

nErr = ICAMERA_SetSize(pMe->pICamera, &pMe->ImageSize);

Set the display size of the device.

nErr = ICAMERA_SetDisplaySize(pMe->pICamera, &pMe->ImageSize);

Set the preview type. This example sets the preview type to snapshot.

																							CAM_PREVIEW_SNAPSHOT, 0);

Set the output media. This example sets the output media for a snapshot.

//set media data output to a file with the name SNAPSHOT_FILE_NAME
 md.clsData = MMD_FILE_NAME;
 md.pData = (void*)SNAPSHOT_FILE_NAME; // a constant in the sample app
 md.dwSize = 0;
 nErr = ICAMERA_SetMediaData(pMe->pICamera, &md,"image/jpeg");

Verify that ICamera is in the ready mode.

ICAMERA_GetMode(pMe->pICamera, &nMode, NULL);
if(nMode == CAM_MODE_READY)
   // continue

Change the ICamera object's mode to preview (CAM_MODE_PREVIEW). This will trigger a series of asynchronous events that are delivered to the application via the callback function.

 //change the mode to preview
 nErr = ICAMERA_Preview(pMe->pICamera);

In the callback function, handle the CAM_STATUS_FRAME status:

   // A new frame is available, Get the raw frame, check orientation and blit it to the screen
   IBitmap * pFrame;
   AEEBitmapInfo BitmapInfo;
   ICAMERA_GetFrame( pMe->pICamera, &pFrame );
   if (!pFrame) break;

   //Check to see if the raw frame does not have the same orientation 
   // as what expected.  If they are not the same, rotate the preview so
   // that the final image on the screen is rotated correctly.  This 
   // will handle the different mounting positions of the camera.
   IBitmap_GetInfo(pFrame, &BitmapInfo, sizeof(AEEBitmapInfo));

   if ( == pMe-> && == pMe-> )
      DBGPRINTF("Frame is %d by %d.  Expected %d by %d",,, 
																									pMe->, pMe-> );
      if (!pMe->bAdjustedPreviewRotate)
         nErr = ICAMERA_SetParm(pMe->pICamera, CAM_PARM_ROTATE_PREVIEW, 90, 0);
         DBGPRINTF("Rotating the image - nErr is %d", nErr);
         pMe->bAdjustedPreviewRotate = TRUE;

   IDISPLAY_BitBlt(pMe->Applet.m_pIDisplay, 0, 0, pMe->, pMe->,  
                         pFrame, 0, 0, AEE_RO_COPY);

   //Display buffer is now updated, need to update the screen