• Advertisement
Sign in to follow this  

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

This topic is 4491 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Sign in to follow this  

  • Advertisement