Refreshing/Flushing screen to display several bitmaps ...
Login to reply to this topic.
mar, 2008-12-02 15:40
Joined: 2008-07-17
Forum posts: 8

Hi,

I created several functions to display a picture for a given time :

  • ShowSplashDisplay : to display a splash screen picture
  • Show2ndDisplay : to display an other picture during my program execution

I don't succeed to display two pictures in the same program execution.

In the current configuration (code below), only the last picture is displayed, in the first seconds I get the default symbian screen.
Both pictures are correctly loaded : I tried to switch the iBackgroundImage* variable : the first picture is displayed. It looks not to be a ressource nor a picture loading pb.
The first picture is not displayed.

If I comment the Show2ndDisplay() and I try to call it in a menu event, only the splash picture is displayed...The screen is not refreshed.

Have you an idea ?
I tried to gc.Clear the display before to display an other picture, to flush with the iEikonEnv->WsSession().Flush() function, to
gc.Activate()/gc.Deactivate(),...
I googled the net, and I haven't found much documentations on Symbian graphics.

Here is the code, I took the Graphics example (in the the S60Ex folder) to do my test :

void CGraphicsAppView::ConstructL( const TRect& aRect )
{
{Loading pictures from MBM, some initialisations}
iBackgroundImage0 = AknIconUtils::CreateIconL(*iIconProvider, EMbmGraphicsappimagesSplash);

iBackgroundImage1 = AknIconUtils::CreateIconL(*iIconProvider, EMbmGraphicsappimagesStep1);

ScaleImages();

// Activate the window, which makes it ready to be drawn
ActivateL();
}

void CGraphicsAppView::Draw( const TRect& /*aRect*/ ) const
{
// The system GC will already be activated when this function is called
// by the framework
ShowSplashDisplay();
}

void CGraphicsAppView::ShowSplashDisplay() const
{
CWindowGc& gc = SystemGc();
// Blit the background image onto the screen at the top left position
gc.BitBlt( Rect().iTl,iBackgroundImage0 );
User::After(1*1000*1000); //1s
gc.Deactivate();
}

void CGraphicsAppView::Show2ndDisplay() const
{
CWindowGc& gc = SystemGc();
gc.Activate( *DrawableWindow() );
// Blit the background image onto the screen at the top left position
gc.BitBlt( Rect().iTl,iBackgroundImage1 );
User::After(1*1000*1000); //1s
gc.Deactivate();
}

void CGraphicsAppView::Draw( const TRect& /*aRect*/ ) const
{
// The system GC will already be activated when this function is called
// by the framework
ShowSplashDisplay();
Show2ndDisplay();
}


mar, 2008-12-02 18:04
Joined: 2008-07-17
Forum posts: 8

I updated my source code :

at begining iScreenType = 0;

void CGraphicsAppView::Draw( const TRect& /*aRect*/ ) const
    {  
    switch( iScreenType )
        {
        case 1 :
            Show2ndDisplay();
            break;
        case 0 :
        default:
            ShowSplashDisplay();
            break;
        }
    }

When I let the pair gc.Activate( *DrawableWindow() ); and gc.Deactivate(); I get a WSERV 10 panic :
"Attempted to activate an already active graphics context. ".
When I start the application the splash screen is displayed then when I click in my menu item corresponding to the Show2ndDisplay() I set the iScreenType variable and the panic is raised.

When i remove the pair Activate/Deactivate I get a WSERV 9 panic :
"A drawing request was sent to a graphics context when the context was not active. "

I don't understand :/
Can somebody please tell me where am I going wrong.
Thanks.

mer, 2008-12-03 09:41
Joined: 2004-11-29
Forum posts: 1419

as long as your function is called from within a draw function, you should neither call activate, nor deactivate.
I notice you have a lone gc.Deactivate() in your "ShowSplashScreen".

Remove them all...

Also, you should absolutely not call User::After from within a draw function, that can make the view framework timeout and give you a ViewSrv::11 panic.
Draw functions must always return as quickly as possible.

You should let a timer handle the delay, let it change the image to show and call DrawNow after a second.
CPeriodic and a static callback should be convenient for this.

mer, 2008-12-03 09:44
Joined: 2004-11-29
Forum posts: 1419

Your problem with you never seeing the first bitmap could just be because of how the epoc emulator starts up when you start it up from carbide.

Your app actually starts far before the UI is fully initialized, so it probably has time to go to the second image before you get to see it.
Try start epoc from a command prompt, and then just navigate to and start the app like you would on a phone, and you might see your first splash too.

mer, 2008-12-03 11:54
Joined: 2008-07-17
Forum posts: 8

Thank you for your advices alh,

I removed all my activate/deactivate and all User::After.

In my HandleCommandL to handle menu events, I removed my ShowSplashScreen() and Show2ndScren(), I let my SetScreenType function and I added the DrawNow() function at the end: It works, I can change my background as I wanted!

Thx


copyright 2003-2009 NewLC SARL