Read-only archive of the All About Symbian forum (2001–2013) · About this archive

Drawing a gif to the screen on 7650

15 replies · 6,187 views · Started 05 December 2002

How am I supposed to do this load the gif and transform it to bitmap?
Is this necessary?

A Cookbook thread would be nice where simple things can be posted things like:
- opening a file
- closing a file
- playing sounds
- send sms
- Drawing images on the screen
- etc.

Thanks for your answer I found the example and was confused. What is the reason for this conversion ?
How much larger is the bitmap compared to the gif version?

Well its not like you convert a gif file to a bmp file...you just load it to the memory as a bitmap and the blit it to the screen. I cannot answer you the questions since I dont reall yknow how much memory it takes up. A good place to start is the SDK and the Book which explains it a bit better than the SDK. However, the example shows the way it is done!

Ok this explains a little and I on the example did not compile right away but Ill just copypaste the parts needed 😊

Hopefully you have found out how to show the gif,

In order to explain your question on why you need to 'convert' the file:

Many storage formats like GIF and JPG etc (hell, almost all) store files in a more compact (compressed) form on disk. Whereas in order to many screen access quick and easy and devoid of lookups etc, screen access is based on flat memory access (or similar). Hence once you open the gif file, you need to decompress/reformat the data into a flat bitmap, once that is done into a memory buffer, you can bitblt (bit-blitting is similar to memory copy, optimised for screen access and colors etc) to screen buffer for showing onto the screen.

This method is almost standard across most operating platforms from windows to linux (😉 okay guessing on the linux one)

Hope that elightens you 😃

Thanks talk2sk, can you tell me how much larger a bitmapped picture is compared to a gif ??

Could someone give me a wroking example cause im having the same kind of trouble. Could not pick up the essential parts. I just need a code that displays pictures on the screen.

Thanks in advance,
Lance

One of the fastest way, I believe, is to use CPAlbImageViewerBasic class.
You don't need to care about the bitmap, supported images will be displayed on this viewer control, much like Visual Basic image control.

// Place this line in the header file of your view or container
CPAlbImageViewerBasic* iViewer;

// Place this line in the contructor of your view or container
iViewer=CPAlbImageViewerBasicNewL(this,Rect());
iViewer->SetAnimationObserver(this,ETrue);

// Call this to load and display every image you want
iViewer->LoadImageL(_L("C\\Nokia\\Images\\Example.gif"😉,EColor4K);
iViewer->PlayAnimationL(); // support image and animation

* The iViewer must be registered as component control
TInt CountComponentControls() const;
CCoeControl* ComponentControl(TInt aIndex) const;

* Derive your view or container class from
MPAlbAnimationObserver

* Implement or override the following in your view or container class
void Notify(TAnimationEvent aEvent)

* Include this header file
Palbimageviewerbasic.h

* Link against this library
Palbview.lib

Most importantly, you need to add some code to the header file ("Epoc32\Include\Palbimageviewerbasic.h"😉 in order to make everything mentioned above work

1. Remark this line

//#include <MPAlbAnimLoadObserver.h>;

2. Paste the following code to the beginning of the header file

class MPAlbFrameProcessor
{
public
virtual void ProcessFrameL(
const CFbsBitmap& aBitmap,
const CFbsBitmap& aMask,
const TFrameInfo& aFrameInfo);
};

class MPAlbAnimLoaderObserver
{
public
virtual void LoadCancelled();
virtual void LoadCompleted();
virtual void LoadFailed(TInt aError);
};

Hope everything have been made clear.
Note The code only apply to Series 60!

Maybe you guys could explaine this one to me? I understood everything else but this part..

* The iViewer must be registered as component control:
TInt CountComponentControls() const;
CCoeControl* ComponentControl(TInt aIndex) const;

So this CountComponentControls()'s return value should be increased by one? And in ComponentControl() I need to add one case more with iViewer in it?

Without those codes I can run it but nothing appers to emulator's screen and with those codes it just crashes =(

[quote="Anonymous"]So this CountComponentControls()'s return value should be increased by one? And in ComponentControl() I need to add one case more with iViewer in it? =([/quote]

Yes, exactly. (Sorry, I don't know the right term to describe the process of this)
I have also forgot to tell to delete iViewer.

Have you find out where it crashed? May be there is some part I missed out? We have released the software (that supports animated GIF, using this piece of code) and so far so good...

[quote="khanming"]Most importantly, you need to add some code to the header file ("Epoc32\Include\Palbimageviewerbasic.h"😉 in order to make everything mentioned above work:

1. Remark this line

//#include <MPAlbAnimLoadObserver.h>;

2. Paste the following code to the beginning of the header file

class MPAlbFrameProcessor
{
public:
virtual void ProcessFrameL(
const CFbsBitmap& aBitmap,
const CFbsBitmap& aMask,
const TFrameInfo& aFrameInfo);
};

class MPAlbAnimLoaderObserver
{
public:
virtual void LoadCancelled();
virtual void LoadCompleted();
virtual void LoadFailed(TInt aError);
};[/quote]

Note that if you are using the latest Series 60 SDK v1.00, you may skip the above procedure, because MPAlbAnimLoadObserver.h header file is already included in this version.

Thanks khanming =)

Guess I'm too lazy to debug =/ I added some of your code one line too early which made it to crash.

I want to show the gif file on screen.I don't know how can I complete the
Notify(TAnimationEvent aEvent) function.Where can I find the sample code about showing gif file ??

Hello,

As I am a total beginner to c++ and OOP, could anybody please help me by showing where exactly (!) to put the code, which was presented by 'guest' in post #9?

It seems to me that displaying .gif files is rather difficult for beginners, as I can see from different developer forums.

Could anybody please alter the 'helloworld' example which is provided with the series 60 sdk to give us a working example and not just code snippets?

For you guys it is 'just' a question of minutes but for stupid beginners like me it will litteraly take weeks until it will work properly.

Any help will be appreciated. Thank you very much.

Kind regards, Lars

It's me again. That is, what I tried altering the 'helloworld' example which came with the series 60 sdk 1.2:

* Step 1:

// Place this line in the header file of your view or container
CPAlbImageViewerBasic* iViewer;

* My try 1:

I chose the 'helloworldappview.h' header and put it right at the beginning of the 'class CHelloWorldAppView : public CCoeControl' definition. When I added 'typedef' in front of it, Error 1 disappeared.

* Result 1:

Error1 (Type name expected)
Error2 (Declaration missing)

* Question 1:

How should the missing declaration look like?

* Step 2:

// Place this line in the contructor of your view or container
iViewer=CPAlbImageViewerBasicNewL(this,Rect());
iViewer->SetAnimationObserver(this,ETrue);

* My try 2:

I put this into the construct function 'void CHelloWorldAppView::ConstructL(const TRect& aRect)' in 'helloworldappview.cpp'.

* Result 2:

Error1 (Undefined symbol 'iViewer' in function CHelloWorldAppView::ConstructL(const TRect &😉)
Error2 (Call to undefined function 'CPAlbImageViewerBasicNewL' in function CHelloWorldAppView::ConstructL(const TRect &😉)

* Step 3:

// Call this to load and display every image you want
iViewer->LoadImageL(_L("C\\Nokia\\Images\\Example.gif"😉,EColor4K);
iViewer->PlayAnimationL(); // support image and animation

* My try 3:

I put this into the draw function 'void CHelloWorldAppView:😃raw(const TRect& /*aRect*/) const' in 'helloworldappview.cpp'

* Result 3:

Error (Undefined symbol 'iViewer' in function CHelloWorldAppView:😃raw(const TRect &😉 const)

* Step 4:

// The iViewer must be registered as component control
TInt CountComponentControls() const;
CCoeControl* ComponentControl(TInt aIndex) const;

* My try 4:

I put this into the 'helloworldappview.h' right at the beginning of the 'class CHelloWorldAppView : public CCoeControl' declaration.

* Step 5:

// Derive your view or container class from
MPAlbAnimationObserver

* My try 5:

I put 'class MPAlbAnimationObserver' into the 'helloworlddocument.h' by extending the forward references right at the beginning.

* Result 5:

All errors except the 'missing declaration' are gone.

* Step 6:

// Implement or override the following in your view or container class
void Notify(TAnimationEvent aEvent)

* My try 6:

I did not put this anywhere, as 'notify events' is already contained in 'PAlbImageViewerBasic.h'.

* Step 7:

// Include this header file
Palbimageviewerbasic.h

* My try 7:

I put '#include "Palbimageviewerbasic.h"' into 'helloworld.cpp'.

* Question 7:

Do I have to include it in any further files?

* Step 8:

// Link against this library
Palbview.lib

* My try 8:

I extended the list in 'helloworld.mmp' with 'LIBRARY Palbview.lib'.

* Step 9:

// need to add some code to the header file ("Epoc32\Include\Palbimageviewerbasic.h"😉 [...] Note that if you are using the latest Series 60 SDK v1.00, you may skip the above procedure, because MPAlbAnimLoadObserver.h header file is already included in this version.

* My try 9:

I did not alter the file as I am using series 60 sdk 1.2, but I cannot see any 'MPAlbAnimLoadObserver.h' file in the 'include' directory. At least '#include <MPAlbAnimLoadObserver.h>' is included in the 'Palbimageviewerbasic.h' file.

* Question 9:

Is the 'MPAlbAnimLoadObserver.h' missing in the series 60 sdk 1.2?

Any ideas?

Kind regards, Lars