# 取得位图的尺寸

### Getting the dimensions of a bitmap

For CBitmap objects we can use the GetBitmap() function to determine the height and width of the bitmap.


BITMAP bm;
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


BITMAP bm;
::GetObject( hBmp, ( bm ), &bm );
bmWidth = bm.bmWidth;
bmHeight = bm.bmHeight;


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

	CFile file;

;

;

(bmfHeader.bfType != ((WORD) ('M' << 8) | 'B'))  ;

;