Solved

CBitmap::LoadBitmap()

Posted on 1998-02-19
9
1,526 Views
Last Modified: 2013-11-20
I'm trying to load a bitmap into a CBitmap object and have no problem when I use the ID
    BmpOb.LoadBitmap(ID_MY_BMP)

but when I try to use the actual bitmap path
    BmpOb.LoadBitmap("c:\\mydir\\mybmp.bmp")

it won't load. How do I go about loading a bmp using a string?
0
Comment
Question by:Grailman
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 7

Expert Comment

by:galkin
Comment Utility
LoadBitmap works only with bitmap resource. Use LoadImage Win32 API function to load bitmap from a file
0
 
LVL 1

Author Comment

by:Grailman
Comment Utility
I found a function on the web to read in a BMP and load it to my CBitmap object that works, but when I try to delete it in order to load another BMP I always get assertion errors???

BmpOb.DeleteObject()   // causes assertion errors

0
 
LVL 4

Expert Comment

by:jtwine100697
Comment Utility
You are going to need to tell WHAT assertion is occuring...  Is it asserting because the class' internal object handle is NULL?

Also...  Check out the source code to the function that loads the BMP into the CBitmap object, and check if it is messing around with the object handle.

-=- James.
0
 
LVL 8

Expert Comment

by:MikeP090797
Comment Utility
Why did you rejected galkins answer? The easiest way of loading bitmap is the LoadImage function
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 4

Expert Comment

by:jtwine100697
Comment Utility
Two possible reasons:

   o He has a function to load into a CBitmap
   o The LR_LOADFROMFILE flag to LoadImage(...) is not supported under NT (according to the Docs...).

   Just a thought...

-=- James.

0
 
LVL 8

Expert Comment

by:MikeP090797
Comment Utility
About the first problem, you can use CBitmap::FromHandle() to get it into CBitmap.
0
 
LVL 2

Expert Comment

by:anichini
Comment Utility
I believe LR_LOADFROMFILE is supported on NT 4.0+
it is not supported on any older versions, though.

0
 

Accepted Solution

by:
dr_funfrock earned 50 total points
Comment Utility

 Try CBitmap::Attach( << Bitmap Handle From LoadImage() >> )
   and CBitmap::Detach

0
 
LVL 1

Author Comment

by:Grailman
Comment Utility
Detach() seems to do it ok. Guess just I wasn't paying attention.
Thanks!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now