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.

ataNewL(CCoeEnv::Static()->FsSession(), *ptrC, CImageDecoder::EOptionAlwaysThread));


