×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    45

    C++ coding problem. CFbsBitmap dissapears.

    I use the CameraWrapper engine to capture an image. I then delete the CameraWrapper object and create a new object now using the other camera. My problem is that the captured image dissapears when I delete the CameraWrapper object. Help please.

    Code:
    	CFbsBitmap* iInsetBitmap;
    
    	TRAP(camErr, iCameraWrapper = CCameraEngine::NewL(1,0,this));
    	// MceoCapturedBitmapReady callled here
    	// iInsetBitmap  set to 320 X 240 image
    	iCameraWrapper->ReleaseAndPowerOff();
            delete iCameraWrapper;
    	TRAP(camErr, iCameraWrapper = CCameraEngine::NewL(0,0,this));
            // iInsetBitmap is now NULL
    
    void CCameraHandler::MceoCapturedBitmapReady( CFbsBitmap* aBitmap )
        {
        iInsetBitmap = new (ELeave) CFbsBitmap();
        iInsetBitmap->Create(TSize(320,240), aBitmap->DisplayMode());
        }

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: C++ coding problem. CFbsBitmap dissapears.

    Assuming that you want to make a copy of aBitmap into iInsetBitmap, that would look like
    Code:
    void CCameraHandler::MceoCapturedBitmapReady( CFbsBitmap* aBitmap )
        {
        TRAPD(err,
            iInsetBitmap = new (ELeave) CFbsBitmap();
            User::LeaveIfError(iInsetBitmap->Create(TSize(320,240), aBitmap->DisplayMode()));
            CFbsBitmapDevice *dev=CFbsBitmapDevice::NewL(iInsetBitmap);
            CleanupStack::PushL(dev);
            CFbsBitGc *gc;
            User::LeaveIfError(dev->CreateContext(gc));
            gc->DrawBitmap(TRect(TSize((320,240)),aBitmap);
            delete gc;
            CleanupStack::PopAndDestroy(); // dev
            );
        }
    You may also want to do something with possible errors (perhaps store 'err', and use it to validate iInsetBitmap).

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    45

    Re: C++ coding problem. CFbsBitmap dissapears.

    Thank you wizard_hu_,

    I am already getting a copy of the bitmap using the CBitmapScaler to shrink the original and copy it to the iInsetBitmap.

    My problem is that (it seems to me) if I create the target bitmap inside the MceoCapturedBitmapReady method then the bitmap is owned by the iCameraWrapper object and gets destroyed automatically when I destroy the iCameraWrapper.

    If I create the bitmap in my constructor then the MceoCapturedBitmapReady call to CBitmapScaler fails. I assume this is also an ownership issue.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: C++ coding problem. CFbsBitmap dissapears.

    I see two kinds of ownership
    - iInsetBitmap is clearly owned by you, and it is not destroyed regardless of what happens to the CameraWrapper
    - aBitmap is probably owned by the CameraWrapper object, though I have not checked the documentation now
    Since CBitmapScaler resizes the image in an asynchronous way, you should not "touch" (delete or use for anything) the CameraWrapper object until scaling is complete.

    What kind of failure have you experienced when calling CBitmapScaler::Scale?

  5. #5
    Registered User
    Join Date
    Aug 2009
    Posts
    45

    Re: C++ coding problem. CFbsBitmap dissapears.

    Thanks wizard_hu_

    If I move iInsetBitmap new to my constructor I get the following:
    Code:
    void CCameraHandler::MceoCapturedBitmapReady( CFbsBitmap* aBitmap )
        {
    	//iInsetBitmap = new (ELeave) CFbsBitmap();
    	iInsetBitmap->Create(iInsetSize, aBitmap->DisplayMode());
    	//CleanupStack::PushL( iInsetBitmap );
    	iBitmapScaler = CBitmapScaler::NewL();
    	CleanupStack::PushL( iBitmapScaler );
    	iDBG.DBG(1, ECCameraHandler_MceoCapturedBitmapReady, _L8("here 1"));
    	//iInsetBitmap->SetDisplayMode(aBitmap->DisplayMode());
    	iDBG.DBG(1, ECCameraHandler_MceoCapturedBitmapReady, _L8("here 2"));
    	iBitmapScaler->Scale(&iStatus, *aBitmap, *iInsetBitmap);
    	iDBG.DBG(1, ECCameraHandler_MceoCapturedBitmapReady, _L8("here 3"));
    	iState = EInsetScaleBitmap;
    	SetActive();
    My debug capture:
    2.29.36.061 CCameraHandler_MceoCapturedBitmapReady - start
    2.29.36.086 CCameraHandler_MceoCapturedBitmapReady - aBitmap: 320 x 240
    2.29.36.099 CCameraHandler_MceoCapturedBitmapReady - Scaling Inset
    2.29.36.110 ECCameraHandler_StartSave - start
    2.29.36.124 CCameraHandler_MceoCapturedBitmapReady - here 1
    2.29.36.135 CCameraHandler_MceoCapturedBitmapReady - here 2
    2.29.36.273 COTGTrackerServer Constructor - continue *****************************
    2.29.36.284 COTGTrackerServer Constructor - Restarted, EExitPanic
    2.29.36.293 COTGTrackerServer Constructor - Restarted, ExitCategory=BitmapTransforms
    2.29.36.305 COTGTrackerServer Constructor - Restarted, ExitReason=1
    If I leave the iInsetBitmap new in MceoCapturedBitmapReady I get the following in my RunL:
    Code:
    	case EInsetScaleBitmap:
    			iDBG.DBG(0, ECCameraHandler_RunL, _L8("EInsetScaleBitmap"));
    			iDebugImageBuffer.Format(KDebugImage,iInsetBitmap->SizeInPixels().iWidth,iInsetBitmap->SizeInPixels().iHeight);
    			iDBG.DBG(1, ECCameraHandler_RunL, _L8("iInsetBitmap: %S"),iDebugImageBuffer);
    			CleanupStack::PopAndDestroy( iBitmapScaler );
    		    iCameraWrapper->ReleaseAndPowerOff();
    			iDebugImageBuffer.Format(KDebugImage,iInsetBitmap->SizeInPixels().iWidth,iInsetBitmap->SizeInPixels().iHeight);
    			iDBG.DBG(1, ECCameraHandler_RunL, _L8("after ReleaseAndPowerOff iInsetBitmap: %S"),iDebugImageBuffer);
    
    		    delete iCameraWrapper;
    		    
    			iDBG.DBG(1, ECCameraHandler_RunL, _L8("after delete iCameraWrapper still OK"));
    		    
    			iDebugImageBuffer.Format(KDebugImage,iInsetBitmap->SizeInPixels().iWidth,iInsetBitmap->SizeInPixels().iHeight);
    			iDBG.DBG(1, ECCameraHandler_RunL, _L8("after delete iCameraWrapper, iInsetBitmap: %S"),iDebugImageBuffer);
    My debug capture:
    2.15.01.744 CCameraHandler_RunL - start iStatus=0
    2.15.01.761 CCameraHandler_RunL - EInsetScaleBitmap
    2.15.01.774 CCameraHandler_RunL - iInsetBitmap: 120 x 90
    2.15.01.901 CCameraHandler_RunL - after ReleaseAndPowerOff iInsetBitmap: 120 x 90
    2.15.01.936 CCameraHandler_RunL - after delete iCameraWrapper still OK
    2.15.02.089 COTGTrackerServer Constructor - continue *****************************
    2.15.02.103 COTGTrackerServer Constructor - Restarted, EExitPanic
    2.15.02.118 COTGTrackerServer Constructor - Restarted, ExitCategory=KERN-EXEC
    2.15.02.133 COTGTrackerServer Constructor - Restarted, ExitReason=3

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: C++ coding problem. CFbsBitmap dissapears.

    "BitmapTransforms 1" seems to be ENoDestinationBitmap (http://library.developer.nokia.com/i...PanicEnum.html, the link may need to be opened a second time to work)
    What is the return value of Create? If it returns an error, the destination bitmap really does not exist.
    Note that there is a CleanupStack::PushL without a pair (and also note that member variables are never put on the Cleanup Stack anyway).

Similar Threads

  1. problem with coding...
    By maclun123 in forum Symbian
    Replies: 5
    Last Post: 2009-02-05, 14:36
  2. Coding problem...
    By Dansco in forum Symbian
    Replies: 2
    Last Post: 2008-10-08, 17:48
  3. Replies: 1
    Last Post: 2007-11-27, 02:17
  4. Sample of Binary SMS that dissapears
    By ho3ho3 in forum General Messaging
    Replies: 2
    Last Post: 2007-11-08, 19:37
  5. Coding Problem
    By honeyzan in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2003-06-23, 08:16

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×