生活的天平本不平衡,只有通过努力改变其偏向。

获得BMP文件的长宽

2005-12-03

在用Direct Draw开发的时候,在建立表面的时候,要知道贴上的图片的宽度。如果用手动输入的话,不够灵活。查了一下MSDN,使用下面的方法,顺利解决。

void AddBMPFile( char * szfilepath)
{
if ( NULL == szfilepath) return;
BITMAP bm;
HBITMAP hbitmap;
int  nWidth ,nHeight;
hbitmap = (HBITMAP) LoadImage(NULL, szfilepath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(hbitmap, sizeof(bm), &bm);
nWidth = bm.bmWidth; //所求的宽
nHeight = bm.bmHeight;//所示的高
}/*AddBMPFile*/

作者:lonkil | 分类目录:编程开发 | 标签:

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>