Sign in to follow this  

loading a bitmap with LoadImage() - who'll solve the riddle?

Recommended Posts

I want to create a Sprite containing an Animation which in turns contains Frames pointers to CBitmaps: Sprite* initSprite(){ Animation* animation = new Animation(); animation->addFrame("bitmap.bmp",500); Sprite* sprite = new Sprite(animation); return sprite; } Animation::addFrame looks like this: void Animation::addFrame(LPSTR fileName, long _duration){ totalDuration += _duration; try{ Frame* frame = new Frame(fileName, totalDuration); frames.push_back(frame); if (frames.size() != 0){ currentFrame = frames.begin(); } } catch (BitmapLoadingException){} } The Frame constructor calls LoadImage(), which should return a handle to a valid bitmap but fails to do so Animation::Frame::Frame(LPSTR fileName, long _endTime):bitmap(NULL){ HBITMAP hBitmap = (HBITMAP)LoadImage(NULL, fileName, IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE); throw BitmapLoadingException(); bitmap->Attach(hBitmap); endTime = _endTime; } where bitmap is a Frame member pointer to a CBitmap I get a debugger message: hBitmap 0x36050c13 {unused=??? } HBITMAP__ * unused CXX0030: Error: expression cannot be evaluated int On one hand hBitmap is assigned a new value, but on the other is doesn't seem to refer to a valid bitmap (which is loaded ok by the same code in another program) Does anyone know what the reason may be? Krzysiek

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this