Loading Bitmap

Login to reply to this topic.
Wed, 2008-06-04 07:55
Joined: 2008-05-12
Forum posts: 16

Hi,

I am developing a sample game of arkanoid. I displayed the whole GUI using draw function n making eclipse but i want to display the same by using bitmap but while do so i am getting an error in enum value ie

CWsBitmap* neb = iEikonEnv->CreateBitmapL(_L("\\resource\\apps\\animation.mbm"), EMbmAnimationNebula);

for loading the bit map i have add following codes::

in mmp file

start bitmap DemoBitmap.mbm
header
sourcepath ..\gfx
source c8 bricks.bmp
end

LIBRARY fbscli.lib
LIBRARY bitgdi.lib
-----------------------------------------------------------
In AppView

// in constructL
void CBrickGameAppView::ConstructL(const TRect& aRect)
{
// Create a window for this application view
CreateWindowL();

// Load in the bitmap images from the multi bitmap file
_LIT( KFullBitName, "\\resource\\apps\\Try.mbm" );
TFileName filePath( KFullBitName );
User::LeaveIfError( 0 );

iBitmap = new (ELeave) CFbsBitmap();
User::LeaveIfError ( iBitmap->Load( filePath, EBitmapDrawViewId1 ));

// Set the windows size
SetRect(aRect);

// Activate the window, which makes it ready to be drawn
ActivateL();
}
- - - - - - - - - - - - - -- - - - - - - - -
In Draw
gc.Clear(aRect);
gc.BitBlt(aRect.iTl, iBitmap);

but its not displaying anything
and sometimes it show error as BMCONV failed and sometime as mbg file not found while its creating .mbg file

Can anybody help me what wrong I am doing and whats the error in my code.
If not so the plz tell me step by step process of loading bitmap.
I have already spend a whole day in doing soo
reply ASAP, its urgents.

Thanks and Regards
Amrish


Thu, 2008-06-05 08:17
Joined: 2004-11-29
Forum posts: 1155
Re: Loading Bitmap

Well this:

start bitmap DemoBitmap.mbm
header
sourcepath ..\gfx
source c8 bricks.bmp
end

is obviously not the definition for the bitmap collection "animation.mbm".

How do you define "animation.mbm"?

The enum is supposed to exist in the mbg file that is generated when it generates animation.mbm

Somtimes bitmap generation is a bit weird... You could try build from commandline, and try to clean up with "reallyclean" and re-build.
Sometimes you have to build two times because he doesn't find the header the first time.

Thu, 2008-06-05 11:14
Joined: 2008-05-12
Forum posts: 16
Re: Loading Bitmap

Thanks for your reply::

below is my code and are only hte changes i made

in mmp
START BITMAP Demo2.mbm
TARGETPATH \resource\apps
HEADER
SOURCEPATH ..\gfx
SOURCE c12 bricks.bmp
END

Library added

LIBRARY fbscli.lib
LIBRARY bitgdi.lib

<i><b>in appview</b></i>
#include <coemain.h>
#include <eikenv.h>
#include "demo2.mbg"
#include <fbs.h>

#include "Demo2AppView.h"

_LIT( KFullBitName, "\\resource\\apps\\Demo2.mbm" );


void CDemo2AppView::ConstructL(const TRect& aRect)
{
// Create a window for this application view
CreateWindowL();


TFileName filePath( KFullBitName );
User::LeaveIfError( 0 );
iBitmap = new (ELeave) CFbsBitmap();
User::LeaveIfError ( iBitmap->Load( filePath, EMbmDemo2Bricks ));

// Set the windows size
SetRect(aRect);

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

void CDemo2AppView:Draw(const TRect& /*aRect*/) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();

// Gets the control's extent
TRect drawRect(Rect());
TRect aRect;
// Clears the screen
gc.Clear(drawRect);
gc.BitBlt(aRect.iTl, iBitmap);

}

i have checked its creating mbm file and mbg file as well .
As per compilation view there no error but its not displaying any bitmap on screen.
i have heared abt mbmviewer but dont knw how exactly it is used. can u plz guide me and plz do tell me where
m going wrong why its not displaying anything i have build that more than 2 times

Thu, 2008-06-05 12:36
Joined: 2005-11-20
Forum posts: 1143
Re: Loading Bitmap

Shouldn't that be

gc.BitBlt(drawRect.iTl, iBitmap);

I don't see the role of 'aRect' in your code.


René Brunner

Thu, 2008-06-05 12:45
Joined: 2003-12-05
Forum posts: 604
Re: Loading Bitmap

TFileName filePath( KFullBitName );
User::LeaveIfError( 0 );  // <<< WHAT IS THIS?!?!?!
iBitmap = new (ELeave) CFbsBitmap();

Thu, 2008-06-05 14:30
Joined: 2004-11-29
Forum posts: 1155
Re: Loading Bitmap

These lines:

TRect aRect;
// Clears the screen
gc.Clear(drawRect);
gc.BitBlt(aRect.iTl, iBitmap);

Will draw your bitmap on an (almost) random position... That position most likely is outside the screen.
aRect is un-initialized, and will have whatever value happens to be left on the stack.

It looks like you got a compilation error because you have commented out the "aRect" argument, but didn't know what you should do, so you just declared a variable, and got rid of the compilation error.

But... A program has to make sense too, not just compile, to work Eye-wink

Remove all crazy-code from your class, and think through what each line really do (and yes, I mean _every_ line), and I'm sure you will get it to work.

  • Login to reply to this topic.