A quick method to load a bitmap file in a CBitmap

WEBINAR: On-demand webcast

How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >

A Quicker way to load *.BMP files into a CBitmap Object

  1. Create your own CBitmap derived class (say, CMyBitmap)
  2. add a "load from bitmap" method as listed below

BOOL CMyBitmap::LoadBitmap(LPCTSTR szFilename) 
{ 
	ASSERT(szFilename);
	DeleteObject();

	HBITMAP hBitmap = NULL; 
	hBitmap = (HBITMAP)LoadImage(NULL, szFilename, IMAGE_BITMAP, 0, 0, 
		LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE); 
	return Attach(hBitmap); 
}



Comments

  • A nice work

    Posted by Legacy on 09/15/2003 12:00am

    Originally posted by: KEYAN

    good work.\

    Reply
  • You are a god

    Posted by Legacy on 08/12/2003 12:00am

    Originally posted by: Jason

    You are a god

    Reply
  • Thanx But....

    Posted by Legacy on 05/16/2003 12:00am

    Originally posted by: Filali

    Thank you for this code
    but can u please tell us
    how to access to a specific Pixel int the bitmap
    i mean the rgb values
    Thanx in advance

    Reply
  • nice 1

    Posted by Legacy on 05/15/2003 12:00am

    Originally posted by: Peter Horsley

    nice werk - this is a genuine gold snipet of code!!!!

    thanks a billion ;)

    Reply
  • It doesn't work with pathnames with directories

    Posted by Legacy on 04/28/2003 12:00am

    Originally posted by: Sveto

    ... for example "e:\somefile.bmp". Only works with "somefile.bmp"

    • yes it does

      Posted by l00p1n6 on 08/11/2005 02:27pm

      u have to use "e:\\somefile.bmp"

      Reply
    Reply
  • how do i start programming for patteren recognition from basics

    Posted by Legacy on 02/26/2003 12:00am

    Originally posted by: shivaji

    i did not understand how to start off with writing an application which involves an image input (code).I have to learn this in order to accomplish a small image segmentation problem (in VC++).


    can you please guide me .

    thank you.

    • image segmentation

      Posted by nmquan2504 on 11/25/2007 06:21am

      i need it

      Reply
    Reply
  • Oh ya!

    Posted by Legacy on 02/25/2003 12:00am

    Originally posted by: Mike

    I have been looking for this simple method for sooooooo long. Thanks dude!

    • good

      Posted by yangds_001 on 05/11/2008 03:00am

      thank you

      Reply
    Reply
  • Very nice!!

    Posted by Legacy on 11/15/2002 12:00am

    Originally posted by: Razvan


    Hello

    Actually you are loading a DIB in a CBitmap; after that you can just StretchBlt the DIB to any device (screen, printer) and the conversion from DIB to DDB is done automatically!!
    Well... that means that the function StretchDIBits is NOT required any more... perhaps I didn't understood something here...
    Is StretchDIBits() required when using this technique?


    Razvan

    Reply
  • Thanks, this is what I needed

    Posted by Legacy on 09/20/2002 12:00am

    Originally posted by: cc

    I've been searching days for a solution to import a bmp image from a file, and all MS documents and samples I found only show how to add a BMP image from the resource file (staticly). Your a life saver :)

    Reply
  • Loading many picture frames

    Posted by Legacy on 12/14/2001 12:00am

    Originally posted by: CK

    Hi,

    May I know how I can go about loading many picture frames, instead of just 1.... thanks...

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date