about offscreen bitmap
| Wed, 2004-09-22 07:21 | |
|
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! |
|







Forum posts: 115
If you are, try add iClient.Flush() after blitting to gc, may be it would help...
CellaGameS.com
Forum posts: 51
thanks!
Forum posts: 115
Does it help ?
CellaGameS.com
Forum posts: 51
Thank you for helping me.. bu it still does not draw the bitmap..
im really confused, the graphics example of the sdk works perfectly on the emulator, but my code does not.
thanks!
Forum posts: 26
// 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?
Cortii
by the way, i still have no luck at drawing offscreen bitmaps..
Forum posts: 115
CellaGameS.com
Forum posts: 1
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!
Forum posts: 63
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