Loading Bitmap
| Wed, 2008-06-04 07:55 | |
|
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 LIBRARY fbscli.lib // Load in the bitmap images from the multi bitmap file iBitmap = new (ELeave) CFbsBitmap(); // Set the windows size // Activate the window, which makes it ready to be drawn but its not displaying anything Can anybody help me what wrong I am doing and whats the error in my code. Thanks and Regards |
|






Forum posts: 1155
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.
Forum posts: 16
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
Forum posts: 1143
Shouldn't that be
gc.BitBlt(drawRect.iTl, iBitmap);I don't see the role of 'aRect' in your code.
René Brunner
Forum posts: 604
TFileName filePath( KFullBitName );User::LeaveIfError( 0 ); // <<< WHAT IS THIS?!?!?!
iBitmap = new (ELeave) CFbsBitmap();
Forum posts: 1155
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
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.