CImageDecoder / *.png
Login to reply to this topic.
Tue, 2008-02-26 10:30
Joined: 2008-02-26
Forum posts: 9

i'm trying to bring a png pic into my project, but ran into a world of trouble with the CImageDecoder class... this is what i tried to do:

RFs Fss;
Fss.Connect();
const TBufC<16> Filename = _L("map.png");
const TBufC<8> Mime = _L("image/png");
CImageDecoder ImageDecoder =
       CImageDecoder::FileNewL( &Fss, &Filename, &Mime, CImageDecoder::EOptionNone );

the last line gives me nine errors stating all the different CImageDecoder::FileNewL() formats
so what am i doing wrong?


Tue, 2008-02-26 10:36
Joined: 2004-11-29
Forum posts: 1419

That means there is some mismatch in argument types.
If you read it, it will actually tell you exactly what the problem is (though can be hard to interpret without good C++ knowledge)

Maybe because those strange const strings you have tried to declare.

A much better way to declare those would be with the _LIT macro:

_LIT(FileName,"map.png");
_LIT(Mime,"image/png");

Try that first...

Oh.. also, you should not have the & on the Fss...

Tue, 2008-02-26 10:41
Joined: 2008-02-26
Forum posts: 9

still getting the same story with the following:

RFs Fss;
Fss.Connect();
_LIT(Filename,"map.png");
_LIT(Mime,"image/png");
CImageDecoder ImageDecoder = CImageDecoder::FileNewL( Fss, &Filename, &Mime, CImageDecoder::EOptionNone );

out of the error messages, this is the one i'm trying to accomplish: (first one in the sdk help)
CImageDecoder::FileNewL(RFs &, const TDesC16 &, const TDesC8 &, const CImageDecoder::TOptions)

Tue, 2008-02-26 10:58
Joined: 2004-11-29
Forum posts: 1419

oh, you shouldn't have an & on any of them.

The & in the function declaration just means it will take a reference to the object instead of doing a copy. (basic C++ stuff)

Try this:

RFs Fss;
Fss.Connect();
_LIT(Filename,"map.png");
_LIT8(Mime,"image/png");  //This needs to be an 8 bit descriptor for some reason...
CImageDecoder ImageDecoder = CImageDecoder::FileNewL( Fss, Filename, Mime, CImageDecoder::EOptionNone );

Also, if you are writing an application, you can get a reference to the current file server session (already opened by the framework) by calling

CCoeEnv::Static()->FsSession()

or.. if your code is within a CCoeControl class, you can get it even quicker by

iCoeEnv->FsSession()

Tue, 2008-02-26 11:03
Joined: 2008-02-26
Forum posts: 9

that gives me:
illegal implicit conversion from 'CImageDecoder *' to

and if i add a * : CImageDecoder* ImageDecoder = ....
i get the following:
Undefined symbol: 'class CImageDecoder * CImageDecoder::FileNewL(class RFs &, class TDesC16 const &, class TDesC8 const &, enum CImageDecoder::TOptions) (?FileNewL@CImageDecoder@@SAPAV1@AAVRFs@@ABVTDesC16@@ABVTDesC8@@W4TOptions@1@@Z)'[]

'least it's a different error Smiling

Tue, 2008-02-26 11:09
Joined: 2004-11-29
Forum posts: 1419

Oh, didn't notice you didn't have the * there, ofcourse its needed Smiling
I think you might need to get a C++ book, and a basic symbian book and read through...
Your next step before this is proper symbian code is to add error and resource handling with cleanupstack and protect against leaves.

Your new error is a link error because you havn't included the library in the mmp file.
you need to add a line to it:

LIBRARY imageconversion.lib

Tue, 2008-02-26 11:15
Joined: 2008-02-26
Forum posts: 9

ah of course i forgot the library, works now, thanks Smiling

i didn't include error handling and such in the post just to keep it simple, since it only protects against runtime errors and doesn't affect the compiling (as far as i know), i'll obviously be adding those Smiling

Wed, 2008-03-05 10:33
Joined: 2008-02-26
Forum posts: 9

made some progress after the holiday, but still no png on the screen...
this is what i'm doing (in AppView::ConstructL for the moment, will be placing it elsewhere at some point) :

_LIT(Filename,"c:\\map.png");
_LIT8(Mime,"image/png");
RFs Fs;
User::LeaveIfError( Fs.Connect() );
CImageDecoder* ImageDecoder;
TRAPD(err, ImageDecoder = CImageDecoder::FileNewL( Fs, Filename, Mime, CImageDecoder::EOptionNone ) );
if (err != KErrNone)
        {
        Fs.Close();
        // die
        }
Fs.Close();
iMappi = new (ELeave) CFbsBitmap;
err2 = iMappi->Create(ImageDecoder->FrameInfo().iOverallSizeInPixels, ImageDecoder->FrameInfo().iFrameDisplayMode );
TRequestStatus ReqStat;
ImageDecoder->Convert(&ReqStat,*iMappi);
if (ReqStat != KErrNone)
        {
        TInt asdf; // just for debugging
        }

and then i use gc.BitBlt(TPoint(0,0),iMappi); to draw it (in AppView::Draw)
it seems that the Convert method isn't doing anything - regardless of whether i comment it out or not, the program prints me a blank white rectangle of the size of the .png file, and it returns KErrNone (doesn't go to TInt asdf;)

Thu, 2008-04-03 13:23
Joined: 2004-11-29
Forum posts: 1419

Late reply, and you probably have fixed this already, but you have to wait for the conversion to finish too.

Convert is an asynchronous call, and probably you try draw it before it is done converting the image.

a call to User::WaitForRequest(ReqStat); after the call to convert will block your thread until it is done.

Sat, 2008-11-08 13:58
Joined: 2008-10-17
Forum posts: 18

Hi,
I have problem,where i have to convert a in memory windows bitmap into CFbsBitmap;
I have used the CImageDecoder::DataNewL(); API to create a decoder.....but the problem is that when i try to convert using User::WaitForRequest(ReqStat) it simply doesnt come out of the loop and the system panics after some seconds.....

I tried creating a active object and using the SetActive() method...but the problem is i have to display the decoded image imediately after the convert function is called.....

Its something like i have a function drawimage( inmemorybitmapstream ) which gets called from the draw( )method...in this drawimage() function i have to convert it into a symbian bitmap and draw the image....i tried using User::WaitForRequest(ReqStat) but it simply panics...wen i try the same using a CDecoder::filenewl() [ Ofcourse using a persistant file Smiling ] instead of using a DataNewL() function everything seems to work perfectly....

How do i do this???

Wed, 2008-11-12 10:18
Joined: 2004-11-29
Forum posts: 1419

You should create your decoder with EOptionAlwaysThread.

An asynchronous request must be performed in a separate thread for User::WaitForRequest() to work.

Mon, 2008-12-22 02:37
Joined: 2008-05-14
Forum posts: 3

you'd better to see some c++ knownledge

used like this:
CImageDecoder::FileNewL( Fss, Filename, Mime, CImageDecoder::EOptionNone );
will be fine.


copyright 2003-2009 NewLC SARL