×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    338

    Problem after converting image file to bitmap ?

    hi,
    I am using CCamera for image viewing and capturing image. The example was very easy in the wiki. I could viiew frame, take snaps and
    save the snaps.. those were easy. The snap i got as hbufc8 and i wrote in a file. I tried the following code snippet to read the image file and convert to bitmap.. I could do so.. But the problem arises after converting to bitmap... Even after the decoder accmplishes successfully the image file is not released... At that time i found KErrInUse -14. Please look at the following code if i have made any mistake.
    Code:
    void CImageHandler::ConvertToBitmap(const TDesC16& aFileName)
    	{
    	WRITELOG(_L("ConvertToBitmap"));
    	TBuf8<255> ImageType;
    
    	GetFileType(aFileName, ImageType);
    
    	if(ImageType.Length() && aFileName.Length())
    		{
    		Cancel();
    		iImageDecoder = CImageDecoder::FileNewL(CCoeEnv::Static()->FsSession(),aFileName,ImageType);
    		delete iFrame;
    		iFrame = NULL;
    		iFrame = new(ELeave)CFbsBitmap();
    		iFrame->Create(iImageDecoder->FrameInfo(0).iOverallSizeInPixels,iImageDecoder->FrameInfo(0).iFrameDisplayMode);
    		iState = EConverting;
    		iImageDecoder->Convert(&iStatus,*iFrame,0);
    		SetActive();
    		}
    	else
    		{
    		TRequestStatus* status=&iStatus;
    		User::RequestComplete(status, KErrNotSupported);
    		SetActive();
    		}
    	}
    
    void CImageHandler::GetFileType(const TDesC& aFileName, TDes8& aFileType)
           {
    	TEntry FileEntry;
     
    	if(CCoeEnv::Static()->FsSession().Entry(aFileName,FileEntry) == KErrNone)
    	{
    		TBuf8<255> FileBuffer;
     
    		if(!FileEntry.IsDir())
    		{
    			TInt FileSize = FileEntry.iSize;
     
    			if(FileSize > 255)
    			{
    				FileSize = 255;
    			}
    			if(CCoeEnv::Static()->FsSession().ReadFileSection(aFileName,0,FileBuffer,FileSize) == KErrNone)
    			{
    				RApaLsSession RSession;
    				if(RSession.Connect() == KErrNone)
    				{	
    					TDataRecognitionResult FileDataType;
    					RSession.RecognizeData(aFileName,FileBuffer,*&FileDataType);
    					aFileType.Copy(FileDataType.iDataType.Des8());
    					RSession.Close();
    				}
    			}
    		}
    	}	
    }

  2. #2
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,987

    Re: Problem after converting image file to bitmap ?

    Saw a similar thread sometime back, i think you need to close the camera resources before doing any operation on the image captured by it(if you haven't done so & the camera is still active in background).

  3. #3
    Registered User
    Join Date
    Feb 2011
    Posts
    338

    Re: Problem after converting image file to bitmap ?

    while i was saving the hbufC8 format data given by the CCamera, i could save the image.. i mean replace the old image for multiple time.. Multiple snap and "multiple replace" did not do any problem.. but after tried to convert the last saved image to a bitmap.. from that time i am not being not able to replace the old file with the new captured file... the old file is not released.

    Please look at this link...
    http://www.developer.nokia.com/Commu...captured_image

    I save the file as it is done here. After saving the file i deleted the aData. Is it a wrong task to delete it ?
    Another thing is though i am getting "resource in use" but manually i am being able open the saved file by system image-viewer.

  4. #4
    Registered User
    Join Date
    Feb 2011
    Posts
    338

    Re: Problem after converting image file to bitmap ?

    I closed the image file too.

  5. #5
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,987

    Re: Problem after converting image file to bitmap ?

    aData is passed as parameter, no need to delete that

    EDIT: btw are you testing the app with any E series device?
    Last edited by vineet.jain; 2012-01-24 at 18:37.

  6. #6
    Registered User
    Join Date
    Feb 2011
    Posts
    338

    Re: Problem after converting image file to bitmap ?

    Quote Originally Posted by vineet.jain View Post
    aData is passed as parameter, no need to delete that

    EDIT: btw are you testing the app with any E series device?
    I am testing with 6720 classic. And if i don't delete that CCamera will delete it. Is it ?

  7. #7
    Registered User
    Join Date
    Feb 2011
    Posts
    338

    Re: Problem after converting image file to bitmap ?

    When i try to delete the image file manually, it says "unable to delete the file which is open"

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,671

    Re: Problem after converting image file to bitmap ?

    Quote Originally Posted by Md. Kayesh View Post
    I am testing with 6720 classic. And if i don't delete that CCamera will delete it. Is it ?
    I would not bet on that. I rather assume that MCameraObserver::ImageReady transfers the ownership of data to you.

    Back to the original question: do you delete the CImageConverter object after it is done with conversion?

    Remark: that GetFileType thing is Ok, but I think it is overcomplicated: CImageDecoder::FileNewL will tell you if a file is not supported.

  9. #9
    Registered User
    Join Date
    Feb 2011
    Posts
    338

    Re: Problem after converting image file to bitmap ?

    Quote Originally Posted by wizard_hu_ View Post
    I would not bet on that. I rather assume that MCameraObserver::ImageReady transfers the ownership of data to you.

    Back to the original question: do you delete the CImageConverter object after it is done with conversion?

    Remark: that GetFileType thing is Ok, but I think it is overcomplicated: CImageDecoder::FileNewL will tell you if a file is not supported.
    Do you mean the "newly converted bitmap object" as the "CImageConverter object" ? I will try to remove the GetFileType as you suggested.

  10. #10
    Registered User
    Join Date
    Feb 2011
    Posts
    338

    Re: Problem after converting image file to bitmap ?

    I have deleted iImageDecoder after finishing conversion.. Now it works fine.. Proabably you were telling about this object. Thank you. :-)

Similar Threads

  1. Converting into a bitmap
    By srinidhirao in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2009-04-28, 15:14
  2. Bitmap image problem
    By phoneynk in forum Symbian
    Replies: 1
    Last Post: 2007-02-27, 16:38
  3. Creating image file from bitmap.
    By mahavirjain in forum Symbian
    Replies: 3
    Last Post: 2006-06-13, 06:48
  4. converting from bitmap to jpg
    By basarim in forum Symbian
    Replies: 1
    Last Post: 2004-03-11, 06:57

Posting Permissions

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