Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Registered User jillemash's Avatar
    Join Date
    Sep 2008
    Posts
    22
    Hi,

    I am trying to use CImageDecoder:ataNewL to create an image from a char *, but no matter how I do it, this method crashes with Panic USER 0.

    I took my inspiration from from this thread (http://discussion.forum.nokia.com/fo...d.php?t=116967), which loads the data from a file. When I do that, CImageDecoder:ataNewL does not crash. When I inspect memory with Carbide debugger, I think I find my image data alright.

    I can not figure out what went wrong, I am quite new to symbian dev.

    Here's my imaga data :
    Code:
    {   0X89 ,0X50, 0X4E, 0X47, 0X0D, 0X0A, 0X1A, 0X0A, 0X00, 0X00, 0X00, 0X0D, 0X49, 0X48, 0X44, 0X52
    		  , 0X00, 0X00, 0X00, 0X09, 0X00, 0X00, 0X00, 0X09, 0X08, 0X02, 0X00, 0X00, 0X00, 0X6F, 0XF3, 0X91
    		  , 0X47, 0X00, 0X00, 0X00, 0X01, 0X73, 0X52, 0X47, 0X42, 0X00, 0XAE, 0XCE, 0X1C, 0XE9, 0X00, 0X00
    		  ,  0X00, 0X04, 0X67, 0X41, 0X4D, 0X41, 0X00, 0X00, 0XB1, 0X8F, 0X0B, 0XFC, 0X61, 0X05, 0X00, 0X00
    		  ,  0X00, 0X20, 0X63, 0X48, 0X52, 0X4D, 0X00, 0X00, 0X7A, 0X26, 0X00, 0X00, 0X80, 0X84, 0X00, 0X00
    		  ,  0XFA, 0X00, 0X00, 0X00, 0X80, 0XE8, 0X00, 0X00, 0X75, 0X30, 0X00, 0X00, 0XEA, 0X60, 0X00, 0X00
    		  ,  0X3A, 0X98, 0X00, 0X00, 0X17, 0X70, 0X9C, 0XBA, 0X51, 0X3C, 0X00, 0X00, 0X00, 0X24, 0X49, 0X44
    		  ,  0X41, 0X54, 0X18, 0X57, 0X63, 0XFC, 0XFF, 0X9F, 0X01, 0X27, 0X00, 0XCA, 0XE1, 0X42, 0X20, 0X09
    		  ,  0X20, 0X40, 0X93, 0X86, 0X88, 0XE0, 0XD4, 0X44, 0XA1, 0X1C, 0X3E, 0XFB, 0XB0, 0XFA, 0X81, 0X80
    		  ,  0X7D, 0X00, 0XC0, 0X68, 0X7B, 0X86, 0XAE, 0X19, 0X95, 0XB8, 0X00, 0X00, 0X00, 0X00, 0X49, 0X45
    		  ,  0X4E, 0X44, 0XAE, 0X42, 0X60, 0X82
    };
    (it should look like a square smiley icon)

    That's a test I made, but I actually get this data through a char *.

    Maybe data format is wrong, due to type declaration...

    Can anyone provide me with a working code? thanks a lot in advance.

    Here is my code (_data is a char *)

    Code:
    HBufC8 * imgData = HBufC8::NewLC(10*1024);
    CleanupStack::Pop(imgData);
    
    TPtr8 ptrToData = imgData->Des();
    ptrToData.operator =((const TUint8*)_data);
    
    TRAPD(err, idecoder = CImageDecoder::DataNewL(CEikonEnv::Static()->FsSession(), ptrToData, CImageDecoder::EOptionAlwaysThread));

  2. #2
    Registered User jillemash's Avatar
    Join Date
    Sep 2008
    Posts
    22
    ............

  3. #3
    Registered User jillemash's Avatar
    Join Date
    Sep 2008
    Posts
    22
    Okay, after loads of tries and errors, I think I've managed to get this working.

    At least DataNew no longer crashes. Here's my code for the descriptor I pass as parameter (ptrToData):

    Code:
    HBufC8*  imgData = HBufC8::NewLC(1024);
    CleanupStack::Pop(imgData);
    TPtrC8 ptrToData = imgData->Des();
    
    ptrToData.Set((const TUint8*) _data, _imageLength);
    I'm not sure my HBufC8 is of any use, because I don't see any image data in there, even by hovering the mouse over it in Carbide debug mode, or by inspecting memory in Memory view or by adding a watch expression.

    But the info returned by DataNew make me think it has decoded the image (the size infos are correct (9x9)).

    Now my pb is i'm stuck after the call to iDecoder.Convert().
    If I can't work this out, I'll post another thread ...

    Thanks!
    Last edited by jillemash; 2009-06-26 at 09:42.

  4. #4
    Registered User jillemash's Avatar
    Join Date
    Sep 2008
    Posts
    22
    I'm still stuck on WaitForRequest with this :

    Code:
    TRequestStatus aStatus = KRequestPending;
    TRAPD(err, idecoder = CImageDecoder::DataNewL(CEikonEnv::Static()->FsSession(), ptrToData, CImageDecoder::EOptionAlwaysThread)); 
    if(err != 0) 
      return err; 
    TFrameInfo iFrameInfo = idecoder->FrameInfo(0); 
    MyBitmap->Create(iFrameInfo.iOverallSizeInPixels,iFrameInfo.iFrameDisplayMode ); 
    TRAPD(err1,idecoder->Convert( &aStatus, *(MyBitmap),0 )); 
    
    User::WaitForRequest( aStatus ); 
     if(err1 != 0) 
      return err1;
    It works fine fine NewFileL... If I remove the WaitForRequest, I get a E32User-Cbase 46 panic ...

    thanks for your help!

  5. #5
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,673
    that would be normal Stray signal panic, so you should indeed implement it with a Active Object..

  6. #6
    Registered User jillemash's Avatar
    Join Date
    Sep 2008
    Posts
    22
    Hi! Thanks for your answer, symbianyucca.

    I was actually intending to do just that when I noticed your message, and now I get a Panic USER 19...
    So maybe the code I've used to solve the first issue (the DataNewL crash) wasn't that right after all, because according to documentation, something must have gone wrong with my descriptor ...

    Here's my ActiveObject :

    definition :
    Code:
    class imageLoaderAO : public CActive
    	{
    	public:
    	    ~imageLoaderAO();
    	    int loadImageFromByteArray(A * serviceProvider, char * _data, signed int _imageOffset, signed int _imageLength);
    	    static imageLoaderAO * NewL();
    	    static imageLoaderAO * NewLC();
    	    
    	private:
    		imageLoaderAO();
    	    void DoCancel();
    	    void RunL();
    	    TInt RunError(TInt aError);
    	    
    	private:
    		A* sp;
    		TFrameInfo iFrameInfo;
    	    CImageDecoder* idecoder;
    	};
    implementation :

    Code:
    int imageLoaderAO::loadImageFromByteArray(A* serviceProvider, char * _data, signed int _imageOffset, signed int _imageLength)
    	{
    	sp =serviceProvider;
    	
    	//HBufC8*  imgData = HBufC8::NewLC(_flc_imageLength);
    
    	TPtrC8 ptrToData ;//= imgData->Des();
    
    	ptrToData.Set((const TUint8*) _data, _imageLength);
    
    	TRAPD(err, idecoder = CImageDecoder::DataNewL(CEikonEnv::Static()->FsSession(), ptrToData)); 
    	if(err != 0) 
    	  return err; 
    	iFrameInfo = idecoder->FrameInfo(0); 
    	(serviceProvider->_flc_com_flexycore_lcduitarget_S60_lib_CFbsBitmap_F_nLink)->Create(iFrameInfo.iOverallSizeInPixels,iFrameInfo.iFrameDisplayMode ); 
    	TRAPD(err1,idecoder->Convert( &iStatus, *(serviceProvider->my_CFbsBitmap),0 )); 
    
    	SetActive();
    	}
    
    //useless! (no constructL needed)
    imageLoaderAO * imageLoaderAO::NewL()
    	{
    	    imageLoaderAO * self = new (ELeave)imageLoaderAO;
    	    CleanupStack::PushL( self );
    	    return self;
    	}
    imageLoaderAO * imageLoaderAO::NewLC()
    	{
    	imageLoaderAO * self = new (ELeave)imageLoaderAO;
        CleanupStack::PushL( self );
        CleanupStack::Pop();
        return self;
    	}
    imageLoaderAO::imageLoaderAO()
    	:CActive( EPriorityStandard ){
    
    	 CActiveScheduler::Add(this) ;   
    	
    }
    void imageLoaderAO::DoCancel()
    	{
    	idecoder->Cancel();
    	}
    void imageLoaderAO::RunL()
    	{
    	 if( iStatus == KErrNone ) 
    		 {
    		 delete idecoder; 
    //update some var here, removed for clarity sake
    
    		 
    //			_LIT(KImageReady, "Image ready");
    //			iController->NotifyCompletion( KErrNone, KImageReady );
    		 }
    	 else if( iStatus == KErrUnderflow ) 
    		 {
    		 idecoder->ContinueConvert( &iStatus );
    		 SetActive();
    		 }
    	 else if ( iStatus == KErrCorrupt )
    		 {
    //		 _LIT(KImageCorrupt, "Image file corrupted");
    //		 iController->NotifyCompletion( KErrCorrupt, KImageCorrupt );
    		 }
    	 else
    		 {
    //		 // Unknown error
    //		 _LIT( KErrorMsg, "Error while opening image" );
    //		 iController->NotifyCompletion( iStatus.Int(), KErrorMsg );
    		 }
    	 
    	}
    TInt imageLoaderAO::RunError(TInt aError){
    	CActive::RunError(aError);
    }
    
    imageLoaderAO::~imageLoaderAO(){
    
    }
    This class is friend of A.

    I'm starting to be out of ideas >_<...

    PS : I call my loadImageFromByteArray() method from outside to get this done. I've put a breakpoint in RunL, but I never reach it... loadImageFromByteArray() returns direcly... maybe this could help. (Though it sounds normal to me given the asynchronous nature of this call...)

    One more thing, you said it was normal. Could you explain why?
    I mean, the other way of doing works file CImagedecoder :: FileNewL(), and the CImageDecoder::EOptionAlwaysThread + User::WaitForRequest( aStatus ) method seems to be used by other people on these forums...
    Maybe next step is to check on a real device, but I'm not that confident.
    Last edited by jillemash; 2009-06-26 at 16:13.

  7. #7
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,673
    try calling SetActive() it might help..

  8. #8
    Registered User jillemash's Avatar
    Join Date
    Sep 2008
    Posts
    22
    I do, last line of loadImageFromByteArray(), just after idecoder->Convert()...

  9. #9
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,673
    So I assume you are not getting the E32User-Cbase 46 panic anymore, so I would assume that the data is just not correct for some reason..

  10. #10
    Registered User jillemash's Avatar
    Join Date
    Sep 2008
    Posts
    22
    Yes, I'm no longer getting the 46...
    So this let's me with either a wrong way of passing my data to DataNewL (wrong desc, wrong way of initializing it, I don't know) or maybe the data itself...

    I posted my data earlier: I cut and pasted the values given by an hexadecimal editor of a png file I made with MS Paint...

    I've used it a java MIDlet and it worked (Image.createImage(byte [] ...)).

    I'm stuck

    Thanks for your time

  11. #11
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,673
    BTW, from where are you getting the data ?, just wondering why it is on that format..

  12. #12
    Registered User jillemash's Avatar
    Join Date
    Sep 2008
    Posts
    22
    It's just that I want to be able to load a png file from a byte array (to mimic what I did with the MIDlet).
    That's why I get this char * pointing to my hand made array as an input.

  13. #13
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,673
    so it is for curiosity and not actually a requirement, so can you just get the image in a descriptor directly, and forget the char's ?

  14. #14
    Registered User jillemash's Avatar
    Join Date
    Sep 2008
    Posts
    22
    Well, I'm afraid not ...

    It's something I must do at work and I don't think I can choose the way the data are given to me.

    And it would have also saved me if it had worked with the first solution, i.e. no active object

  15. #15
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,673
    are you sure, can you tell me on how the application gets the data in the first place ?

Page 1 of 2 12 LastLast

Similar Threads

  1. Can I load a cfbsbitmap without resourceid?
    By haoniukun in forum Symbian User Interface
    Replies: 4
    Last Post: 2007-07-01, 06:21
  2. S60 2nd to 3rd/ PlatformSecurity / Capabilities
    By jarkoos in forum Symbian Signed Support, Application Packaging and Distribution and Security
    Replies: 4
    Last Post: 2007-04-14, 14:08
  3. Replies: 1
    Last Post: 2006-11-15, 07:03
  4. socket read hangs until socket is closed
    By camroe in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2005-07-21, 09:44
  5. How to load .png into CFbsBitmap?
    By pa3ot in forum Symbian C++
    Replies: 1
    Last Post: 2003-06-27, 10:35

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved