A quick method to load a bitmap file in a CBitmap

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

  • Wholesale Oakley Radarlock free shipping

    Posted by vwaemyhpd on 06/26/2013 07:30pm

    Oakley For Cheap ,Oakley glasses developed in the usa for the first time the founder from the motorcycle handle and then sell his or her label of motorcycle events and achievements of famous designer sunglasses and ski goggles. Advertisements and runway shows, designer eye glasses accessories using their program - that doesn't belong the sunglasses - either clear lenses or only slightly tinted color lens. fake oakley sunglasses ,All lens offers truer color perception in sunny conditions are good purpose, three points suitable to hold the lens precise optical alignment of comfort and performance. Oakley generally is a gift of an perfect man and woman. These types of are popular on the planet. Oakley when needed is often out to upgrade. Fake Oakley Holbrook ,For a lot of species, they never walk out fashion, for other people may change while using the seasons, if your sunglasses for way less than to purchase a difference fourfold 1 year with virtually no problems. Sunglasses are employed every single day, giving her a very accessories of goods and in addition focuses on sports activities and actions, whether you desire something plain and chic or perhaps a bright and unique. Movement to keep a top-notch frame and comfortable standpoint, to defend the role of eye-safe, and also due to must replace the sun lens. Each Oakley shade to offer personal fun. Services are given with the requirements that face men and ladies, Oakley glasses extremely exciting choice. You should use in biochemistry Labrador, in addition to wood processing. They can be used in the snow track and field, plus in swimming. Cheap Oakley sunglasses, the idea of subversion it's comfortable, practical, artistic, and integration glasses. I always know that we are going to succeed. This belief originates from you believe the ongoing cause, to make every effort to offer the ultimate perfection. Addition, plutonite contacts provides a many ultra-violet sun rays of the sun 100% protection, and special protection of influence. Sun screen lotion is generally determined to besides understand that you might have already installed a stylish plus much more attractive appearance, that's actually a sensible way to protect you resist the harsh sunlight. Do you want prescription sunglasses or maybe want quality accessories to make sure you receive whatever you pay for, you will discover individuals who offer online Oakley suppliers.

    Reply
  • 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, Please Wait ...

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

Top White Papers and Webcasts

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds