Getting the dimensions of a bitmap

For CBitmap objects we can use the GetBitmap() function to determine the height and width of the bitmap.
	// The variable bitmap is a CBitmap object
	bitmap.GetBitmap( &bm );
	bmWidth = bm.bmWidth;
	bmHeight = bm.bmHeight;

If you have a HBITMAP, you can attach it to a CBitmap object and use the method shown above or you can use

	// The variable hBmp is a HBITMAP
	::GetObject( hBmp, sizeof( bm ), &bm );
	bmWidth = bm.bmWidth;
	bmHeight = bm.bmHeight;

For images in a BMP file, you can use something like

	CFile file;
	// sBMPFileName is the BMP filename
	if( !file.Open( sBMPFileName, CFile::modeRead) )
		return ;


	// Read file header
	if (file.Read((LPSTR)&bmfHeader, sizeof(bmfHeader)) != sizeof(bmfHeader))
		return ;

	// File type should be 'BM'
	if (bmfHeader.bfType != ((WORD) ('M' << 8) | 'B'))
		return ;

	if (file.Read((LPSTR)&bmiHeader, sizeof(bmiHeader)) != sizeof(bmiHeader))
		return ;

	int bmWidth = bmiHeader.biWidth;
	int bmHeight = bmiHeader.biHeight;


  • Fake Oakley Drizzle low price for sale

    Posted by sjvwoqjem on 06/26/2013 06:14pm

    Ray Ban Clearance ,Oakley sunglasses created to change annually, the same as another style?? However, the alternatives are very different game situations, there isn't a truly fashion. The fashion brand focuses around the trend of glasses exist within the field strengthened. These measures include high-end luxury brands in Europe, as well as contemporary U.S. brand Brooks Brothers at the top to take into account. Fake Oakleys ,Oakley ski goggles will give you amazing feeling, the most up-to-date model and design more pleasing and stylish glasses. The unique design and precision manufacturing touch, in the brand, to ensure each set of two sunglasses masterpiece. They'll agree in a style, design and elegance. Oakley bIg taco Sunglasses ,Will be difference between and ordinary OAKLEY sunglasses discount? This is a a number of sizes, shapes and fashoins to demonstrate off your attitude, discussing with you, and to echo your personality. There is no need the very best of the most beneficial to obtain the best. You truly can give the elements on the show too although if you need to alter the look of your face, it really is easy. To find out nowhere, pale yellow and pink lenses are not made for wear in bright light, his or her anti-reflective capacity is weak. Women waiting to get combined with the usage of previously they would choose to purchase additional, nearly every period of a performance together for his or her special handbags purses and handbags, in many months. The most protection on the eyes, HDO upgrade lens 100% UV filtering also produces the most important and best quality mats to make the certain durability. Concisely, not during the summer time of Oakley sun screen lotion, close to noon, for the Four Seasons, the surrounding sea or sailing or at high altitude snowboarding. Oakley sunglasses shape and stainless metal injection molding, setting up a convenient button to discharge each shot, the handle towards smallest detail. A perpetual lens coating in order to avoid rain and sweat building for the lens, the exclusion of skin oils as well as other contaminants, so the lens is smudge and easy to hold clean. OAKLEY truly accurate optical technology, expensive Strengthening research for countless years along with the firm manufacturing. You can find the best company, providing high-quality products, budget friendly cost towards the minutes of the best pattern, variety, sunglasses add-ons monitor.

  • Getting RGB values from BMP, PNG and JPEG

    Posted by jahly on 11/12/2007 08:23pm

    Can anyone help me how to get the RGB values of BMP, PNG and JPEG image file formats? in c/c++ plz.. Thank you...

  • Where can I find information about Bitmap

    Posted by Kambiz on 02/25/2007 01:33pm

    I am new (with Visual c++ and MFC) I tried to show a bitmap but couldn't. All CBitmap HBitmap & Bitmap is too much. Where can i find more info about how to handle with Bitmaps? Anybody who can help me with show a Bitmap or even better where I can find more info? thanks

  • how to get 704X576 pixel bitmat in VC++

    Posted by ushaji_cs on 04/01/2006 01:48am

    i am getting the image format 352X288 pixel format i want a big size 704X576 pixel format. when i am calling the video format dialog it is automatically going to 352X288 pixel format, but in windows 98 its comming properly , but in windows Xp it is not working.

  • How to read a bmp image into an array buffer in openGL

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

    Originally posted by: Barun Sarker

    kindly send me the code to read the bmp image pixel by pixel and store it in an array using openGL

  • to obtain the pixel map of a .bmp image

    Posted by Legacy on 02/17/2004 12:00am

    Originally posted by: nathalie

    I want to have a list of the pixels contained in a .bmp image.
    I think I could store them in a buffer.
    But does anyone know which function is appropriate to do this?
    After that, the buffer of pixels will be used in an OpenGL application (written in Visual Basic).
    If you know a better way to analyse a .bmp image in OpenGL, tell me.
    Thank you :-)

  • to display an bmp image in linux env using a c program

    Posted by Legacy on 02/17/2004 12:00am

    Originally posted by: naveen

    can u send me a C code to open a bmp image and extract all its characters in structure,also to display it in linux env.

  • Displaying 8bit images from file onto dialog and increase the brightness as required

    Posted by Legacy on 01/07/2004 12:00am

    Originally posted by: Raghavendra

    How to display a 8bit image from file and how to perform brightness operation on the displayed file.Please help me

  • c

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

    Originally posted by: jeeva

    how to read bitmap files in c?
    how to write bitmap files in c?

  • How can i change a CBitmap object to an other CBitmap object

    Posted by Legacy on 11/17/2003 12:00am

    Originally posted by: Fernando

    i put this in c++
    CBitmap object1, object2, temp;

    temp = object1;
    object1 = object2;
    object2 = temp;

    and this gets me an error, because i can't use '=' with a CBitmap object, how can i do that?

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