Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

CBitmap::LoadBitmap()

Posted on 1998-02-19
9
1,537 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
ID: 1316391
LoadBitmap works only with bitmap resource. Use LoadImage Win32 API function to load bitmap from a file
0
 
LVL 1

Author Comment

by:Grailman
ID: 1316392
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
ID: 1316393
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 8

Expert Comment

by:MikeP090797
ID: 1316394
Why did you rejected galkins answer? The easiest way of loading bitmap is the LoadImage function
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1316395
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
ID: 1316396
About the first problem, you can use CBitmap::FromHandle() to get it into CBitmap.
0
 
LVL 2

Expert Comment

by:anichini
ID: 1316397
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
ID: 1316398

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

0
 
LVL 1

Author Comment

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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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