3rd edition Bitmap for background
| Mon, 2006-12-25 14:27 | |
|
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); } |
|






Forum posts: 123
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
Forum posts: 145
Thank you very much for your reply ,
and you have a good point in that last sentanceÂ
I tried to use gc.DrawBitmap(aRect, bitmap) instead of gc.BitBlt(TPoint(0,0),bitmap) - didn't get any results
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
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);
  }
}
Forum posts: 145
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
Thank you & Have a great and happy new year
Forum posts: 123
sorry for this late reply. was on holidays
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
Forum posts: 145
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 !!!