3rd edition Bitmap for background

Login to reply to this topic.
Mon, 2006-12-25 14:27
Joined: 2005-09-04
Forum posts: 145
Hi

I want to use Bitmap as a view background,
I create the MBM in the MMP (like in 2nd edition) ,
but when I open the view , the picture seems bad (weired colors, stuff that didn't happen in 2nd edition).
also the picture is too high and I think that it somehow prevents the menu and title from showing.

My question is: how do I use MBM in 3rd edition?
what should I change?
(its not clear from the porting docs and I couldnt find a good example application for this in the SDK)

The code I use :
Code:
void CMyAppViewContainer::Draw(const TRect& aRect) const
{
       CWindowGc& gc = SystemGc();
       gc.Clear(Rect());
       _LIT(KMBMFileName, "%c:\\system\\apps\\myapp\\mymbm.mbm");
       TBuf<50> mbmFileName;
       mbmFileName.Format(KMBMFileName,'c');
       CFbsBitmap* bitmap = new (ELeave) CFbsBitmap();
       TInt err = bitmap->Load(mbmFileName);
       if (err!=KErrNone)
               User::Leave(err);
       CleanupStack::PushL(bitmap);
       gc.BitBlt(TPoint(0,0),bitmap);
       CleanupStack::PopAndDestroy(bitmap);
}

Mon, 2006-12-25 23:30
Joined: 2004-07-12
Forum posts: 123
Re: 3rd edition Bitmap for background
Bill,

How did you include the MBM details in the MMP file? can you include your code?
Also what device are you using?

The thing is when you define an MBM in the MMP file you will be defining its color depth as well as in the following:

START BITMAP        MyGame.mbm

HEADER
TARGETPATH          ..\..\..\..\wins\c\system\apps\MyGame
SOURCEPATH          ..\MyBitmaps
//                  color-depth   source-bitmap
SOURCE              c12           image1.bmp
END

note that the depth here for image1 is 12bits per pixel.

Now if your device is having 24bits per pixel or 32 by default the window server will try to map the low bit-depth (12) to the high one (24 or 32) and here you will have unexpected results!!

a solution for this is:
1) eaither you make sure that the bitmap (image1.bmp in the example above) being defined for MBM in MMP has a color depth approperiate to the default one used by the device. To retrieve this depth use the following:

void CMyAppContainer::ConstructL()
{
// make sure that this line is used in a class that is derived
// from CCoeControl
TDisplayMode mode = Window().DisplayMode();
...
}


2) or you set the depth of the window server to the one that meets your original bitmap file (iamge1.bmp). you can do something like this:

void CMyAppContainer::ConstructL()
{
// make sure that this line is used in a class that is derived
// from CCoeControl
Window()SetRequiredDisplayMode();
...
}

hope this helps
Abolfoooud

PS: what are uou doing at this time mate in front of yout pc? go enjoy the Christmas Cheezy

Fri, 2006-12-29 15:18
Joined: 2005-09-04
Forum posts: 145
Re: 3rd edition Bitmap for background
Hi
Thank you very much for your reply ,
and you have a good point in that last sentance  Wink

I tried to use gc.DrawBitmap(aRect, bitmap) instead of gc.BitBlt(TPoint(0,0),bitmap) - didn't get any results Sad

I also tried to use Window().SetRequiredDisplayMode(TDisplayMode) in the container's ConstructL with the possible TDisplayMode values (and also used Window().DisplayMode()) but with no improvement (The only actual change was when I tried the Gray values - but I use colors).

I also changed the MBM conf from c8 to c12 but with no change.

Here is some additional code from the View class and the MMP file,
maybe you can give me other ideas of how to solve this ...

Thank you very much

Code:

START BITMAP mymbm.mbm
  #if defined(WINSCW)
  TARGETPATH ..\..\winscw\c\myapp
  #else
  TARGETPATH ..\..\data\Z\Resource\apps
  #endif
      HEADER
      SOURCEPATH ..\data
      SOURCE c12 image.bmp
      SOURCE 1 imagemask.bmp//also tried without this line
END

void CMyAppView::DoActivateL(const TVwsViewId&,TUid,const TDesC8&)
{
if ( !iContainer )
    {
iContainer = CMyAppViewContainer::NewL(this);
        iContainer->SetMopParent(this);
TRect rect = ClientRect();
iContainer->ConstructL(rect);
        AppUi()->AddToStackL(*this, iContainer);
SetTitlePaneL();
        iContainer->MakeVisible(ETrue);
    }
}
Sun, 2006-12-31 17:48
Joined: 2005-09-04
Forum posts: 145
Re: 3rd edition Bitmap for background
Using SetRect in the Container's ConstructL made the image fit the view and show the Commands and title.

The only problem left regarding this issue is that the image still looks bad on the Emulator while the original bmp file looks great.
It sounds that this is related to a depth issye , but as you can see on me previous posts on this Thread ,
This problem still exists although I tried some possible solutions.

I will keep try and I hope maybe to get some ideas from here also Smiley

Thank you & Have a great and happy new year

Tue, 2007-01-02 12:19
Joined: 2004-07-12
Forum posts: 123
Re: 3rd edition Bitmap for background
Bill,

sorry for this late reply. was on holidays Cheezy

I presume you are using an N-series device. These devices have EColor16MU (24bits) or EColor16MA (32bits) display modes. You are still trying to set the small display mode (12bits) to one of these high bit-depths. try using c24 instead of c12 in:

SOURCE c12 image.bmp  ===>  SOURCE c24 image.bmp

i gues it would work like this.

hope this helps
AF
Fri, 2007-01-05 13:13
Joined: 2005-09-04
Forum posts: 145
Re: 3rd edition Bitmap for background
abolfoooud  again thank you very much Smiley

The problem was in the mask file (The same mask file which worked on 2nd edition) ,
Painting it all black solved the problem and the image looks as the original on emulator even if I use c8 ...

Have a great weekend !!!
  • Login to reply to this topic.