Mercurial > s60_experiments
diff DemoCube/src/DemoCubeAppView.cpp @ 1:0a2b5a968ce7
Modifications that turn this Nokia-supplied DemoCube demo into a web-browser mockup that uses optical flow for panning operations.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Tue, 12 Feb 2008 17:32:01 -0600 |
parents | 43361e733c66 |
children | f546bb5370c7 |
line wrap: on
line diff
--- a/DemoCube/src/DemoCubeAppView.cpp Tue Feb 12 17:18:02 2008 -0600 +++ b/DemoCube/src/DemoCubeAppView.cpp Tue Feb 12 17:32:01 2008 -0600 @@ -23,10 +23,13 @@ #include "ncvOpticalFlow.h" #include "ncvEgoMovement.h" #include "DemoCube.h" +#include "ImageLoader.h" #define PADDING_WIDTH 40 #define PADDING_HEIGHT 30 +_LIT( KPicture, "firefox.png" ); + // ============================ MEMBER FUNCTIONS =============================== // ----------------------------------------------------------------------------- @@ -67,6 +70,7 @@ TPoint tmp(0, 0); iCubePoints->AppendL(tmp); } + // Create a window for this application view CreateWindowL(); @@ -77,6 +81,21 @@ ActivateL(); } +void CDemoCubeAppView::StartImgLoader() +{ + // was 50,50 + TSize iSize(493, 305); + TInt color; + TInt gray; + TDisplayMode displayMode = CEikonEnv::Static()->WsSession().GetDefModeMaxNumColors( color, gray ); + + iPicture = new (ELeave) CFbsBitmap; + if (iPicture) + iPicture->Create(iSize, displayMode); //EColor16MA + iLoader = CImageLoader::NewL( 'c' ); + iLoader->LoadImage( KPicture, iPicture ); +} + // ----------------------------------------------------------------------------- // CDemoCubeAppView::CDemoCubeAppView() // C++ default constructor can NOT contain any code, that might leave. @@ -89,7 +108,9 @@ iBitmapSize(25, 18), iCamus(NULL), iOpticalFlow(NULL), - iCube(NULL) + iCube(NULL), + iLoader(NULL), + iPicture(NULL) { } @@ -138,6 +159,16 @@ delete iCubePoints; iCubePoints = NULL; } + if(iLoader) + { + delete iLoader; + iLoader = NULL; + } + if(iPicture) + { + delete iPicture; + iPicture = NULL; + } } // ----------------------------------------------------------------------------- @@ -145,14 +176,18 @@ // Draws the display. // ----------------------------------------------------------------------------- // -void CDemoCubeAppView::Draw(CFbsBitmap& aBitmap, CArrayFixFlat<TPoint>* aCube) const +void CDemoCubeAppView::Draw(CFbsBitmap& aBitmap, CArrayFixFlat<TPoint>* aCube) { CWindowGc& gc = SystemGc(); gc.Activate(Window()); gc.Clear(); - gc.BitBlt(TPoint(PADDING_WIDTH / 2, PADDING_HEIGHT / 2), &aBitmap); - gc.SetPenColor(TRgb(0xff, 0, 0)); - gc.DrawPolyLine(aCube); + //gc.BitBlt(TPoint(PADDING_WIDTH / 2, PADDING_HEIGHT / 2), &aBitmap); + + + //gc.BitBlt(TPoint(PADDING_WIDTH / 2, PADDING_HEIGHT / 2), iPicture); + gc.BitBlt(TPoint( (TInt)iMove.iY.Real(), (TInt)iMove.iX.Real()), iPicture); + //gc.SetPenColor(TRgb(0xff, 0, 0)); + //gc.DrawPolyLine(aCube); gc.Deactivate(); iCoeEnv->WsSession().Flush(); } @@ -175,7 +210,7 @@ iCamus->GetOpticalFlow(*iOpticalFlow, *iCamusImage, CAMUS_SETCAMUSOPTS(CCamus::EMedium, CCamus::EMedium, 3)); CEgoMovement mean = iOpticalFlow->Mean(); iMove.iX -= mean.iX * 6.3; - iMove.iY += mean.iY * 6.3; + iMove.iY -= mean.iY * 6.3; iAngle += iOpticalFlow->Rotation().Real() * 10.5; //