CImageDecoder / *.png
| Tue, 2008-02-26 10:30 | |
|
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;the last line gives me nine errors stating all the different CImageDecoder::FileNewL() formats |
|






Forum posts: 1134
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...
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)
Forum posts: 1134
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:
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
or.. if your code is within a CCoeControl class, you can get it even quicker by
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
Forum posts: 1134
Oh, didn't notice you didn't have the * there, ofcourse its needed
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
Forum posts: 9
ah of course i forgot the library, works now, thanks
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
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;)
Forum posts: 1134
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.