How encode image data to a descriptor, not file ? urgent!!!
| Wed, 2005-04-27 10:58 | |
|
Hi ,
I'm developing some AP about image manipulating . Now some problem for your help . I can encode image data into a file by create encoder by CImageEncoder::FileNewL(), but can't encode them into a descriptor ? Why ? part code as following : To a file is OK !!! ============================================== void CImageConverterEngine::EncodeToFile( TFileName& aFileName, TUid aImageType, TUid aImageSubType) { delete iImageEncoder; iImageEncoder = NULL; // create the encoder iImageEncoder = CImageEncoder::FileNewL( iFs, aFileName, CImageEncoder::EOptionNone, aImageType, aImageSubType ); iState = EEncoding; iImageEncoder->Convert( &iStatus, *iBitmap ); SetActive(); } =============================================== To a descriptor has some problem ******************************************************* definition of some argument // HBufC8* iBufC8 = HBufC8::NewL(850); // void CImageConverterEngine::EncodeToDescriptor( HBufC8*& aBufferName, TUid aImageType, TUid aImageSubType) { delete iImageEncoder; iImageEncoder = NULL; // create the encoder iImageEncoder = CImageEncoder::DataNewL(aBufferName, CImageEncoder::EOptionNone, aImageType, aImageSubType ); // ap will exit when run here iState = EEncoding; TBmpImageData* imageDataBMP = new (ELeave) TBmpImageData; imageDataBMP->iBitsPerPixel = 1; CFrameImageData* iFrameImageDataBMP = CFrameImageData::NewL(); User::LeaveIfError(iFrameImageDataBMP->AppendImageData(imageDataBMP)); iImageEncoder->Convert( &iStatus, *iBitmap, iFrameImageDataBMP ); SetActive(); } ********************************************************* Why my ap will exit when run at the iImageEncoder = CImageEncoder::DataNewL(aBufferName, CImageEncoder::EOptionNone, aImageType, aImageSubType ); or maybe there is something wrong in the definition of HBufC8* iBufC8 = HBufC8::NewL(850); Thanks very much for your help . And looking for word to your reply deeply !!! Howard |
|






Forum posts: 1379
Maybe the output buffer isn't big enough?
didster
Forum posts: 14
Maybe the output buffer isn't big enough?
Hi, didster, thanks so much for your reply .
But as your advice, I try to trap the panic . But not any useful result . By the S60 SDK's Help, the API DataNewL(), it seem that it won't return any panic when certain error occur .
Could you give me some other effective advice ?
Thank you in advance .
Howard
Forum posts: 1379
If your app is panicing, the whats the panic code? Does it show "Program closed, my app name"?
didster
Forum posts: 14
Yes , as you said , my ap will leave with the notification "Progarmme closed my ap name" . Is this leave or panic ? Anyhow , the notification will appear and ap exit .
And I can't trap any useful data for my ap .
Really thanks deeply for your help , didster .
Howard[/url]
Forum posts: 12
but i could not say how to solve that problem
, i just say one tip you should study base C++ about pointer
sorry, but i hope this tip and information helpful to you.
Forum posts: 27
Even I have the same problem. I think the problem is with the buffer
HBufC8* iBufC8 = HBufC8::NewL(850);
Plz let me know If you have solved this problem.
Thanks in advance
Forum posts: 8
I just meet this error today, and now I have solved it .
The error occurs the following code:
HBufC8* iBufC8 = HBufC8::NewL(850);
When I pay attention to the parameter HBufC8*& aBufferName of CImageEncoder::DataNewL function, it's a *& type. So the buffer will be allocated in the function of CImageEncoder::DataNewL , then assign the start address to the aBufferName, which is reference of income pointer. So, if use a pointer which is already point to memory space on the heap to the CImageEncoder::DataNewL function, will lead to memory leak and the program will exit with panic.
So, the solution is very simple, Just overwirte the following code:
HBufC8* iBufC8 = HBufC8::NewL(850);
to:
HBufC8* iBufC8 = NULL;
Thank OK!
Forum posts: 14
but after i convert image using API function 'Convert'... the pointer is still NULL...
Forum posts: 59