Image data into HBufC8*
| Wed, 2007-04-04 12:31 | |
|
Greetings,
I have tried to read jpg file data into HBufC8* without success. In Forum Nokia I have tried to get help for my problem in this thread: http://discussion.forum.nokia.com/forum/showthread.php?p=297058#post297058 Basically my problem is that CImageEncoder's Convert() method adds only four first characters in HBufC8* just like it did with RFile by doing like this: Code: RFile infile; TInt val=infile.Open(fs,path,EFileShareExclusive|EFileRead); TBuf8<256> data8; infile.Read(data8, 256); data8 includes "ÿØÿá" string JPG file start like this, if I open file with notepad: Code: ÿØÿáXÂExif II* n N73 I did like this to have a bitmap data into HBufC8*: Code: iImageEncoder=CImageEncoder::DataNewL(iBuffer, _L8("image/jpeg"), CImageEncoder::EOptionNone); iState=EEncoding; iImageEncoder->Convert(&iStatus,*iBitmap); SetActive(); iBuffer includes "ÿØÿá" string. Any ideas what is the problem? Regards, Arachidyl |
|






Forum posts: 131
HBufC8* data = HBufC8::NewL(<filesize>);
TPtr8 dataptr = data->Des();
infile.Read(dataptr,<filesize>);
You can reach data with data->Ptr() /TUint8*/
Ro0p
Forum posts: 5
User::LeaveIfError(fs.Connect());
RFile infile;
TInt val=infile.Open(fs,path,EFileStream|EFileRead);
if(val==KErrNone)
{
TInt file_size;
infile.Size(file_size); // file_size =~137000
HBufC8* bufImageData;
bufImageData = HBufC8::NewL(file_size);
TPtr8 ptr_bufImageData=bufImageData->Des();
infile.Read(ptr_bufImageData, file_size); // bufImageData = ÿØÿáXÂExif
const TUint8* temp = ptr_bufImageData.Ptr(); // temp = 610412724
Now it reads 10 characters but that isn't enough. What should I do for const TUint8* temp variable?
- Arachidyl
Forum posts: 131
From SDK help:
Class CImageEncoder
"This class provides functions that convert image data held in CFbsBitmap objects into well know formats and store the results in either files of descriptors."
You need Decoder.
Class CImageDecoder
"This class provides functions to decode images held in files or descriptors. To decode buffered images use the buffered version of this class CBufferedImageDecoder."
Forum posts: 5
I have used CImageDecoder for having jpg image in bitmap:
iBuffer = aBuffer;
delete iImageDecoder;
iImageDecoder = NULL;
delete iBitmap;
iBitmap = NULL;
// create the decoder
iImageDecoder = CImageDecoder::FileNewL( iFs, aFileName );
// create the destination bitmap
iBitmap = new (ELeave) CFbsBitmap();
iBitmap->Create( iImageDecoder->FrameInfo().iOverallSizeInPixels,
iImageDecoder->FrameInfo().iFrameDisplayMode ); ;
// start conversion to bitmap
iState = EDecoding;
iImageDecoder->Convert( &iStatus, *iBitmap );
SetActive();
Forum posts: 5
Both solutions DataNewL and RFile should work.