×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    1

    Problem with image decoding using CImageDecoder::DataNewL

    Hi,

    I have a jpeg an image in a memory buffer and I have to decode it.
    In the next test code I load image directly from a file or I load the file in a memory buffer. In the first case decoding is working. In the second case decoding is not working...

    CFbsBitmap* CImageLoader::LoadL( const TFileName& aFileName, TDisplayMode aDisplayMode )
    {
    TFileName file( iPath );
    file.Append( aFileName );

    CImageDecoder* iConverter = NULL;
    TFrameInfo iFrameInfo;
    CFbsBitmap* pLoader;
    TRequestStatus iConvStatus;
    TInt bError;

    pLoader = new CFbsBitmap();

    if(0)
    {
    // first good case
    //initialise decoder
    TRAPD(Err, iConverter = CImageDecoder::FileNewL(CCoeEnv::Static()->FsSession(), aFileName, CImageDecoder::EOptionAlwaysThread));
    }
    else
    {
    // second wrong case
    // open file
    RFile file; // file to write to
    User::LeaveIfError(file.Open(CCoeEnv::Static()->FsSession(),aFileName,EFileRead));

    int fSize;
    int bErr = file.Size(fSize);
    char* pData = new char[fSize];

    TPtr8 ptr((unsigned char *)pData,fSize);
    ptr.SetLength(fSize);
    TDesC8 *ptrC=(TDesC8 *)&ptr;

    file.Read(ptr, fSize);
    file.Close();

    TRAPD(Err, iConverter = CImageDecoder:ataNewL(CCoeEnv::Static()->FsSession(), *ptrC, CImageDecoder::EOptionAlwaysThread));
    }

    //Get the frame info
    iFrameInfo = iConverter->FrameInfo();

    // create a blank bitmap to copy the image into
    bError = pLoader->Create(iFrameInfo.iOverallSizeInPixels,aDisplayMode);
    if(bError == KErrNone)
    {
    // Convert the image into a bitmap
    iConverter->Convert(&iConvStatus, *pLoader);

    // wait for conversion to complete
    User::WaitForRequest(iConvStatus);

    // clean up
    iConverter->Cancel();
    delete iConverter;
    }

    return pLoader;
    }

    Program is crashing when is doing WaitForRequest... (E32USER-CBase 42)
    Can you advice me how to solve this problem?
    Or how can I decode correctly an image from a memory buffer?

    Thank you.
    Sebi.

  2. #2
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143

    Re: Problem with image decoding using CImageDecoder::DataNewL

    have you checked the SDK help for the error, it says: "This panic is raised by the SetActive() member function of an active object, a CActive. It is caused by an attempt to flag the active object as active when it is already active, i.e. a request is still outstanding."

    So remember to cancel the previous request before starting a new one, or wait till the last one is done, before starting again.

    yucca

Similar Threads

  1. image input element types in form -problem
    By seanos11 in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2004-11-01, 15:25
  2. 7650 Image Uploader strange problem
    By kamlesh_in in forum Symbian
    Replies: 1
    Last Post: 2003-08-25, 15:06
  3. problem using image converter utility
    By gaurav17281 in forum Symbian User Interface
    Replies: 1
    Last Post: 2003-06-16, 05:38
  4. Loading Image data from 'raw' bytes
    By LongSteve in forum Mobile Java General
    Replies: 2
    Last Post: 2002-11-20, 17:38

Posting Permissions

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