Hi guys,
I'm new in symbian c++ and I'm currently trying to load bitmap image. I was able to run my application but an error occured. 1) System error and MyImage
Alloc:3124cd680. Pls see my code below to find out what is wrong with my code.
thanks guys.
ImageLoader.h
#ifndef IMAGELOADER_H_
#define IMAGELOADER_H_
#include <e32base.h>
#include <coecntrl.h>
#include <w32std.h>
#include <e32std.h>
#include <cntdef.h>
#include <cntdb.h>
#include <fbs.h>
//FORWARD DECLARATIONS
class CFbsBitmap;
class ImageLoader : public CCoeControl
{
public:
ImageLoader();
virtual ~ImageLoader();
void LoadImage(const TDesC& aFileName);
void MyDraw(const TRect& /*aRect*/) const;
private:
CFbsBitmap* iBitmap;
};
#endif /*IMAGELOADER_H_*/
ImageLoader.cpp
#include "ImageLoader.h"
ImageLoader::ImageLoader()
{
}
ImageLoader::~ImageLoader()
{
delete iBitmap;
}
void ImageLoader::LoadImage(TDesC16 const& aFileName)
{
iBitmap = new (ELeave) CFbsBitmap;
CleanupStack::PushL(iBitmap);
User::LeaveIfError(iBitmap->Load(aFileName, 1) );
CleanupStack::Pop(iBitmap);
}
void ImageLoader::MyDraw(const TRect& /*aRect*/) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();
// Gets the control's extent
TRect drawRect( Rect());
// Clears the screen
gc.Clear( drawRect );
if(iBitmap)
{
gc.DrawBitmap(Rect(), iBitmap);
}
}
MyImageAppView.cpp
void CMyImageAppView::ConstructL( const TRect& aRect )
{
// Create a window for this application view
CreateWindowL();
// Set the windows size
SetRect( aRect );
//Added #start
ImageLoader* loader = new (ELeave) ImageLoader;
loader->LoadImage(KBitmapName);
loader->MyDraw(aRect);
//Added #end
// Activate the window, which makes it ready to be drawn
ActivateL();
}