about offscreen bitmap

Login to reply to this topic.
Wed, 2004-09-22 07:21
Joined: 2004-08-20
Forum posts: 51
Hi!

Could anyone please help me with this.. i have this in my container class:
Code:
#include "bitmapmethods.h"
#include <game.mbg>

_LIT(KGameMbm, "\\system\\apps\\game\\game.mbm");

CGameMainContainer::CGameMainContainer()
: fade(ETrue), aBlackMap(0), aWhiteMap(255)
{
}

void CGameMainContainer::ConstructL(const TRect& /*aRect*/)
{
CreateWindowL();
TRect screenRect = CEikonEnv::Static()->EikAppUi()->ApplicationRect();
LoadArtL();
iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard);
StartTimerL();
SetRect(screenRect);
ActivateL();
}

void CGameMainContainer::StartTimerL()
{
if(!iPeriodicTimer->IsActive())
iPeriodicTimer->Start(0, 500, TCallBack(CGameMainContainer::Tick, this));
}

void CGameMainContainer::StopTimer()
{
if(iPeriodicTimer)
iPeriodicTimer->Cancel();
}

void CGameMainContainer::LoadArtL()
{
    iBitmap = NBitmapMethods::CreateBitmapL(KGameMbm, EMbmGameTitle);
// Create the off screen bitmap and device / gc
iOffScreenBitmap = NBitmapMethods::CreateBitmapL(Rect().Size(),KColourDepth);
iOffScreenBitmapDevice = NBitmapMethods::CreateBitmapDeviceL(*iOffScreenBitmap);
iOffScreenBitmapGc = NBitmapMethods::CreateGraphicsContextL(*iOffScreenBitmapDevice);
}

void CGameMainContainer::Draw(const TRect& aRect) const
{
UpdateDisplay();
}

void CGameMainContainer::UpdateDisplay() const
{
CWindowGc& gc = SystemGc();
//gc.Clear(aRect);

if(fade)
{
//gc.SetFadingParameters(aBlackMap, aWhiteMap);
//gc.SetFaded(ETrue);
//gc.BitBlt(TPoint(0,0), iBitmap);
iOffScreenBitmapGc->SetFadingParameters(aBlackMap, aWhiteMap);
iOffScreenBitmapGc->SetFaded(ETrue);
iOffScreenBitmapGc->BitBlt(TPoint(0,0), iBitmap);
gc.BitBlt(TPoint(0,0),iOffScreenBitmap);
}
//draw main screen
else
{
//gc.SetFaded(EFalse);
//gc.BitBlt(TPoint(0,0), iBitmap);
iOffScreenBitmapGc->SetFaded(EFalse);
iOffScreenBitmapGc->BitBlt(TPoint(0,0), iBitmap);
gc.BitBlt(Rect().iTl,iOffScreenBitmap);
}
}

TInt CGameMainContainer::Tick(TAny* aObject)
{
//cast and call a non-static function
((CGameMainContainer*)aObject)->DoFade();
return TRUE;
}

void CGameMainContainer::DoFade()
{
CWindowGc& gc = SystemGc();
if(iPeriodicTimer->IsActive())
{
if(aBlackMap < aWhiteMap)
{
aBlackMap += 5;

gc.Activate(*DrawableWindow());
UpdateDisplay();
gc.Deactivate();
//DrawDeferred();
}
else
{
fade = EFalse;
StopTimer();

gc.Activate(*DrawableWindow());
UpdateDisplay();
gc.Deactivate();
//DrawDeferred();
}
}
}

Why is the bitmap not being displayed on the screen of the emulator (although there is no error)? It does not fade either. I used double buffering because using CWindowGc directly causes the screen to flicker (on 3650 and 7650 phones). Could you please point out to me where i did something wrong?

thanks! Smiling


Wed, 2004-09-22 08:52
Joined: 2004-05-23
Forum posts: 115
about offscreen bitmap
Have you checked in the debugger if you are enetering into bitblt ?
If you are, try add iClient.Flush() after blitting to gc, may be it would  help...

Wed, 2004-09-22 11:09
Joined: 2004-08-20
Forum posts: 51
about offscreen bitmap
it is entering into BitBlt.. can i ask what iClient is? What type of object is it?

thanks! Smiling

Wed, 2004-09-22 11:30
Joined: 2004-05-23
Forum posts: 115
about offscreen bitmap
It's a pointer to windows session. It's a member of CAppView framework . Or you can get it from EikonEnv  iEikonEnv->WsSession().Flush() . Flush() send command to windows server to perform all commands (bitblt's etc.) in queue now.

Does it help ?

Thu, 2004-09-23 02:52
Joined: 2004-08-20
Forum posts: 51
about offscreen bitmap
Hi serg3d!

Thank you for helping me.. bu it still does not draw the bitmap..  Cry  i dont understand why my code does not work when i just copied some of it from the graphics example of the sdk.. Huh do you think i should try it on the phone to test it out?

im really confused, the graphics example of the sdk works perfectly on the emulator, but my code does not.

thanks! Smiling

Mon, 2004-09-27 10:55
Joined: 2004-09-14
Forum posts: 26
about offscreen bitmap
I think this is the simpliest way, to draw offscreen bitmap, but when I trying to use this code:

  // Create the off screen bitmap and device / gc
  iOffScreenBitmap = NBitmapMethods::CreateBitmapL(Rect().Size(),KColourDepth);
  iOffScreenBitmapDevice = NBitmapMethods::CreateBitmapDeviceL(*iOffScreenBitmap);
  iOffScreenBitmapGc = NBitmapMethods::CreateGraphicsContextL(*iOffScreenBitmapDevice);

- the debuger says: unresolved external class (CFbsBitmap* ... ect)...

What sould I do to not get this error?  Huh

Cortii

Thu, 2004-09-30 02:49
Anonymous (not verified)
Forum posts: 2043
about offscreen bitmap
did you remember to put
Code:
class CFbsBitmap;
at the beginning of your .h file?

by the way, i still have no luck at drawing offscreen bitmaps.. Sad
Fri, 2004-10-01 17:49
Joined: 2004-05-23
Forum posts: 115
about offscreen bitmap
Hmm, Have you tried brute force approach ? Just take nokia example and modify it step by step until  you will get your app ?

Sun, 2005-06-19 05:01
Joined: 2005-06-19
Forum posts: 1
Re: about offscreen bitmap
Thanks guys,

After looking at your posts, I was able to make my offscreen bitmap work.  My caveats were:
1.  I had to move my bitmap, device, context pointer declarations to  my view class;
2.  I was using TSize() to create my bitmap, it worked when I used Rect().Size() instead;

thanks again for your contributions, I hope to be able to help likewise....

CHeers!
Thu, 2005-08-04 11:33
Joined: 2005-06-24
Forum posts: 63
Re: about offscreen bitmap
Quote from: RyuManila
Thanks guys,

After looking at your posts, I was able to make my offscreen bitmap work.  My caveats were:
1.  I had to move my bitmap, device, context pointer declarations to  my view class;
2.  I was using TSize() to create my bitmap, it worked when I used Rect().Size() instead;

thanks again for your contributions, I hope to be able to help likewise....

CHeers!

hey,  i tried also moving my bitmap, device and context pointer declaration in view class but when i run my app, still no image appears..
i used also Rect().Size()..i even put forward declarations on each class.. but still nothing appears..
..can u give me some of ur codes please so i can try to figure out what's lacking in my code....thanks in advance!
..any
  • Login to reply to this topic.