📄 filmreel2container.cpp
字号:
iCount++;
if (iCount == KTotalNumberOfPictures)
{
// When the collage bitmap is filled, reset the
// iCount to 0, and set iX and iY back to the top-corner
iCount = 0;
iX = 0;
iY = 0;
iContainerState = ESavingImage; // set flag, can't take new pictures when saving
SetNaviLabelTextL(R_SAVING_TEXT);
SaveImageL(); // Save the image to file
}
else
{
iX++; // Increase the horizintal position of the next image
if (iX == KNumberOfPicturesInRow)
{
// If at the end of a row, move to the beginning of the next row.
iY++;
iX = 0;
}
// take next picture.
RequestPictureAfterPause();
}
}
break;
case EDisplayingResult:
// No need to do anything here, if we are displaying the created image
break;
default:
break;
};
}
/**
* Observer method for the Camera Server operations.
* Gets called when the iCamera->Reserve() method has completed.
* @param aError the error value
*/
void CFilmReel2Container::ReserveComplete(TInt aError)
{
if (aError == KErrNone)
{
// Once the camera has been successfully reserved, the
// application will power up the camera.
iCamera->PowerOn();
}
}
/**
* Observer method for the Camera Server operations.
* Gets called when the iCamera->PowerOn() method has completed.
* @param aError the error value
*/
void CFilmReel2Container::PowerOnComplete(TInt aError)
{
if (aError == KErrNone)
{
TRAPD (err, PowerOnCompleteL());
}
}
/**
* Observer method for the Camera Server operations.
* Gets called when the iCamera->StartViewFinderBitmapsL() method has completed.
* @param aBitMap the image from the view finder.
*/
void CFilmReel2Container::ViewFinderFrameReady(CFbsBitmap& aBitMap)
{
TRAPD (err, ViewFinderFrameReadyL(aBitMap));
}
/**
* Observer method for the Camera Server operations.
* Gets called when the iCamera->CaptureImage() when has completed.
* @param aBitmap the image captured.
* @param aData the image data captured (not specified for this example)
* @param aError the error value
*/
void CFilmReel2Container::ImageReady(CFbsBitmap* aBitmap, HBufC8* aData, TInt aError)
{
if (aError == KErrNone && aBitmap)
{
TRAPD (err, ImageReadyL(aBitmap, aData));
}
}
void CFilmReel2Container::FrameBufferReady(MFrameBuffer* /*aFrameBuffer*/, TInt /*aError*/)
{
}
/**
* Returns the current state of the container
* @return the current state of the FilmReel2container
*/
CFilmReel2Container::TContainerState CFilmReel2Container::CurrentState() const
{
return iContainerState;
}
/**
* Changes the container back into previewing mode,
* updating the softkeys and starts the preview loop
*/
void CFilmReel2Container::PreviewModeL()
{
if (iContainerState == EPoweredDown)
{
iCamera->Reserve();
}
if (iContainerState == EDisplayingResult)
{
SetNaviLabelTextL(R_PREVIEWING_TEXT);
CEikButtonGroupContainer* cba = iAvkonAppUi->Cba();
cba->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_EXIT);
TSize size;
iCamera->EnumerateCaptureSizes(size, 1, CCamera::EFormatFbsBitmapColor4K);
iCamera->StartViewFinderBitmapsL(size);
}
}
/**
* Changes the container into recording mode, clearing the collagebitmap
* and slowing down the camera timer.
*/
void CFilmReel2Container::RecordModeL()
{
if (iContainerState == EPreviewing)
{
iCamera->StopViewFinder();
if (iBitmapViewer)
{
iBitmapViewer->Reset();
delete iBitmapViewer;
iBitmapViewer = NULL;
}
iContainerState = ERecording; // switch to recording
SetNaviLabelTextL(R_RECORDING_TEXT);
// Clear the collageBitmap to a white background
iBGc->SetBrushColor(KRgbWhite);
iBGc->Clear();
// Slow down the timer for recording
iCameraTimer->SetDelay(KFilmReel2Speed);
RequestPictureAfterPause();
}
}
/**
* Changes the container state to displaying and updates the softkeys
*/
void CFilmReel2Container::DisplayModeL()
{
if (iContainerState == ESavingImage)
{
// Extract filename from full path
iContainerState = EDisplayingResult;
TParse parseToImageName;
parseToImageName.Set(iFileName, NULL, NULL);
iImageName = parseToImageName.Name();
SetNaviLabelTextL(iImageName);
CEikButtonGroupContainer* cba = iAvkonAppUi->Cba();
cba->SetCommandSetL(R_FILMREEL2_SOFTKEYS_OPTIONS_DELETE);
cba->DrawDeferred();
}
}
/**
* Returns a reference to the filename of the last image saved
*/
const TFileName& CFilmReel2Container::FileName() const
{
return iFileName;
}
/**
* Returns a reference to the name of the last image saved
*/
const TFileName& CFilmReel2Container::ImageName() const
{
return iImageName;
}
/**
* Saves the current collageBitmap to the phone album
*/
void CFilmReel2Container::SaveImageL()
{
// Be sure that we have an image to be saved
HBufC* imageroot = TPAlbSettings::RootImageFolderLC(); // gets the name of the phone album folder
iFileName = *imageroot;
iFileName.Append(KDefaultFileName);
// generate filename using the framework's file server connection
CEikApplication::GenerateFileName(iCoeEnv->FsSession(), iFileName);
CleanupStack::PopAndDestroy(imageroot);
// Create Format and Codec
iFormat->iSettings.iQualityFactor = KJpgSavingQualityFactor; // quality factor from 0 to 100 (55 used here)
iFormat->iSettings.iSampleScheme = TMdaJpgSettings::TColorSampling(TMdaJpgSettings::EColor420);
// Create a file to save the image into
// this is done in an asynch function
iFileSaver->CreateL(iFileName, iFormat, NULL, NULL);
}
/**
* This function is called when the asynchronous function
* iFileSaver->CreateL() completes. Successfully or not. The error value tells if the
* creation was successful. If it was, we have created a file
* into which we can now save the image.
*
* @param aError the error value
*/
void CFilmReel2Container::MiuoCreateComplete(TInt aError)
{
if ((aError == KErrNone) && iFileSaver)
{
// TRAP is used because this function cannot leave (no trailing L; name inherited from observer)
// any error is ignored
TRAPD(error, iFileSaver->ConvertL(*(iCollageBitmap)));
}
}
/**
* This function is called when the asynchronous function
* iFileSaver->ConvertL() completes. Now the image saving has
* completed.
*
* @param aError the error value
*/
void CFilmReel2Container::MiuoConvertComplete(TInt aError)
{
if (!aError)
{
// TRAP is used because this function cannot leave (no trailing L; name inherited from observer)
// any error is ignored
TRAPD(error, DisplayModeL());
}
}
/**
* Observer method for the Media Server operations.
* Gets called when the CMdaImageFileToBitmapUtility has opened
* an image file. Not used here.
*
* @param aError error number, e.g. KErrNone if an error occured
*/
void CFilmReel2Container::MiuoOpenComplete(TInt /*aError*/)
{
}
/**
* Starts the camera timer
*/
void CFilmReel2Container::RequestPictureAfterPause()
{
iCameraTimer->StartTimer();
}
/**
* Called by the camera timer, when the requested time has elasped
* makes a call to the cameramanager to take a picture
*/
void CFilmReel2Container::TimerCompleted()
{
iBitmap->Reset();
iCamera->CaptureImage();
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -