mmplugins/cameraplugins/testapp/testcameraapps60/src/TestCameraApp.cpp
branchRCL_3
changeset 64 92a82bc706f7
parent 9 9ae0fe04e757
equal deleted inserted replaced
9:9ae0fe04e757 64:92a82bc706f7
    87 
    87 
    88 	case ETCamCmdViewFinder:
    88 	case ETCamCmdViewFinder:
    89 		RDebug::Print(_L("CTCamAppUi::HandleCommandL(ETCamCmdViewFinder)"));
    89 		RDebug::Print(_L("CTCamAppUi::HandleCommandL(ETCamCmdViewFinder)"));
    90 
    90 
    91 		ViewFinderL();
    91 		ViewFinderL();
       
    92 
    92 		break;
    93 		break;
    93 
    94 
    94 	case ETCamCmdCaptureImage:
    95 	case ETCamCmdCaptureImage:
    95 		RDebug::Print(_L("CTCamAppUi::HandleCommandL(ETCamCmdCaptureImage)"));
    96 		RDebug::Print(_L("CTCamAppUi::HandleCommandL(ETCamCmdCaptureImage)"));
    96 
    97 
   166 	RDebug::Print(_L("CTCamAppUi::ViewFinderL() iCamera->EnumerateCaptureSizes()_S"));
   167 	RDebug::Print(_L("CTCamAppUi::ViewFinderL() iCamera->EnumerateCaptureSizes()_S"));
   167 	iCamera->EnumerateCaptureSizes(imageSize,1,CCamera::EFormatFbsBitmapColor16M);
   168 	iCamera->EnumerateCaptureSizes(imageSize,1,CCamera::EFormatFbsBitmapColor16M);
   168 	RDebug::Print(_L("CTCamAppUi::ViewFinderL() iCamera->EnumerateCaptureSizes()_E"));
   169 	RDebug::Print(_L("CTCamAppUi::ViewFinderL() iCamera->EnumerateCaptureSizes()_E"));
   169 
   170 
   170 	const TPoint pos = iAppView->DrawBorders(imageSize);
   171 	const TPoint pos = iAppView->DrawBorders(imageSize);
   171 	TRect screenRect(pos,imageSize);
   172 	iScreenRect.SetRect(pos, imageSize);
       
   173 
   172 	TRect clipRect;
   174 	TRect clipRect;
   173 
   175 
   174 	if (!iCamera->ViewFinderActive())
   176 	if (!iCamera->ViewFinderActive())
   175 		{
   177 		{
   176 		RDebug::Print(_L("CTCamAppUi::ViewFinderL() iCamera->StartViewFinderDirectL()_S"));
   178 		iCamera->StartViewFinderDirectL(iCoeEnv->WsSession(),*iCoeEnv->ScreenDevice(),*iAppView->DrawableWindow(),iScreenRect, clipRect);
   177 		iCamera->StartViewFinderDirectL(iCoeEnv->WsSession(),*iCoeEnv->ScreenDevice(),*iAppView->DrawableWindow(),screenRect,clipRect);
       
   178 		RDebug::Print(_L("CTCamAppUi::ViewFinderL() iCamera->StartViewFinderDirectL()_E"));
       
   179 		}
   179 		}
   180 	else
   180 	else
   181 		{
   181 		{
   182 		RDebug::Print(_L("CTCamAppUi::ViewFinderL() iCamera->StopViewFinder()_S"));
   182 //		RDebug::Print(_L("CTCamAppUi::ViewFinderL() iCamera->StopViewFinder()_S"));
   183 		iCamera->StopViewFinder();
   183 //		iCamera->StopViewFinder();
   184 		RDebug::Print(_L("CTCamAppUi::ViewFinderL() iCamera->StopViewFinder()_E"));
   184 //		RDebug::Print(_L("CTCamAppUi::ViewFinderL() iCamera->StopViewFinder()_E"));
   185 		}
   185 		}
   186 	}
   186 	}
   187 
   187 
   188 void CTCamAppUi::CaptureImageL()
   188 void CTCamAppUi::CaptureImageL()
   189 	{
   189 	{
   236 
   236 
   237 	TBuf<KMaxErrLength> msgBuffer;
   237 	TBuf<KMaxErrLength> msgBuffer;
   238 	_LIT(KErrMessage,"CTCamAppUi::ImageReady");
   238 	_LIT(KErrMessage,"CTCamAppUi::ImageReady");
   239 	if (aBitmap)
   239 	if (aBitmap)
   240 		{
   240 		{
   241 		iAppView->DrawImage(aBitmap);
   241 		iAppView->DrawImage(aBitmap, iScreenRect);
   242 		delete aBitmap;
       
   243 		}
   242 		}
   244 	if (aError)
   243 	if (aError)
   245 		{
   244 		{
   246 		msgBuffer.Format(KErrorFormat,aError,&KErrMessage);
   245 		msgBuffer.Format(KErrorFormat,aError,&KErrMessage);
   247 		iEikonEnv->InfoMsg(msgBuffer);
   246 		iEikonEnv->InfoMsg(msgBuffer);
   260 		{
   259 		{
   261 		msgBuffer.Format(KErrorFormat,aError,&KErrMessage);
   260 		msgBuffer.Format(KErrorFormat,aError,&KErrMessage);
   262 		iEikonEnv->InfoMsg(msgBuffer);
   261 		iEikonEnv->InfoMsg(msgBuffer);
   263 		return;
   262 		return;
   264 		}
   263 		}
   265 	TRAPD(error,iAppView->DrawImage(aFrameBuffer->FrameL(0)));
   264 	TRAPD(error,iAppView->DrawImage(aFrameBuffer->FrameL(0), iScreenRect));
   266 	aFrameBuffer->Release();
   265 	aFrameBuffer->Release();
   267 	if (error)
   266 	if (error)
   268 		{
   267 		{
   269 		msgBuffer.Format(KErrorFormat,error,&KErrMessage);
   268 		msgBuffer.Format(KErrorFormat,error,&KErrMessage);
   270 		iEikonEnv->InfoMsg(msgBuffer);
   269 		iEikonEnv->InfoMsg(msgBuffer);
   293 	}
   292 	}
   294 
   293 
   295 CTCamAppView::~CTCamAppView()
   294 CTCamAppView::~CTCamAppView()
   296 	{}
   295 	{}
   297 
   296 
   298 void CTCamAppView::DrawImage(CFbsBitmap* aImage) const
   297 void CTCamAppView::DrawImage(CFbsBitmap* aImage, TRect aScreenRect) const
   299 	{
   298 	{
       
   299 	RDebug::Print(_L("aImage->DataAddress() = %d"),aImage->DataAddress());
       
   300 	// view position setting for test application
       
   301 	RDebug::Print(_L("Set view position_S"));
       
   302 	TRect wRect = aScreenRect;
       
   303 	wRect.iTl.iY = 123;
       
   304 	wRect.iBr.iY = 244;
       
   305 
       
   306 	RDebug::Print(_L("Set view position_E"));
       
   307 	// draw bitmap
   300 	CWindowGc& gc = SystemGc();
   308 	CWindowGc& gc = SystemGc();
   301 	gc.Activate(Window());
   309 	if (IsReadyToDraw())
   302 	TRect drawRect(Rect());
   310 		{
   303 	TPoint pos;
   311 		gc.Activate(Window());
   304 	pos.iX = (drawRect.iBr.iX - aImage->SizeInPixels().iWidth) / 2;
   312 		TBool back = IsBackedUp();
   305 //	pos.iY = (drawRect.iBr.iY - aImage->SizeInPixels().iHeight) / 2;
   313 		if (!back)
   306 	pos.iY = ((drawRect.iBr.iY + 122) - aImage->SizeInPixels().iHeight) / 2;
   314 			{
   307 	gc.BitBlt(pos,aImage);
   315 			Window().Invalidate(wRect);
   308 	gc.Deactivate();
   316 			Window().BeginRedraw(wRect);
       
   317 			}
       
   318 		gc.DrawBitmap(wRect, aImage);
       
   319 		if (!back)
       
   320 			{
       
   321 			Window().EndRedraw();
       
   322 			}
       
   323 		gc.Deactivate();
       
   324 		}
   309 	iCoeEnv->WsSession().Flush();
   325 	iCoeEnv->WsSession().Flush();
   310 	}
   326 	}
   311 
   327 
   312 void CTCamAppView::Draw(const TRect& /*aRect*/) const
   328 void CTCamAppView::Draw(const TRect& /*aRect*/) const
   313 	{
   329 	{
   323 	CWindowGc& gc = SystemGc();
   339 	CWindowGc& gc = SystemGc();
   324 	gc.Activate(Window());
   340 	gc.Activate(Window());
   325 	TRect drawRect(Rect());
   341 	TRect drawRect(Rect());
   326 	TPoint pos;
   342 	TPoint pos;
   327 	pos.iX = (drawRect.iBr.iX - aSize.iWidth) / 2;
   343 	pos.iX = (drawRect.iBr.iX - aSize.iWidth) / 2;
   328 //	pos.iY = (drawRect.iBr.iY - aSize.iHeight) / 2;
       
   329 	pos.iY = ((drawRect.iBr.iY + 122) - aSize.iHeight) / 2;
   344 	pos.iY = ((drawRect.iBr.iY + 122) - aSize.iHeight) / 2;
   330 	TRect border(pos,aSize);
   345 	TRect border(pos,aSize);
   331 	border.Grow(1,1);
   346 	border.Grow(1,1);
   332 	gc.SetPenColor(KRgbBlack);
   347 	gc.SetPenColor(KRgbBlack);
   333 	gc.DrawRect(border);
   348 	gc.DrawRect(border);