小辉程序员之路, since 1996 http://www.xiaohui.com
乐走天涯: 工作并快乐着,职业并休闲着
 » 首页 > Mulitmedia 多媒体: 位图(Bitmap)及图像格式处理

获取位图的大小


http://www.XiaoHui.com 日期: 2002-01-26 13:00

用GetBitmap()函数确定位图的高度和宽度:

// The variable bitmap is a CBitmap object BITMAP bm; bitmap.GetBitmap( &bm ); bmWidth = bm.bmWidth; bmHeight = bm.bmHeight;

如果已有HBITMAP,可以附加它到CBitmap对象:

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

对于BMP文件中的图像,可以采用下面方法:

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 ; BITMAPFILEHEADER bmfHeader; // 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 ; BITMAPINFOHEADER bmiHeader; if (file.Read((LPSTR)&bmiHeader, sizeof(bmiHeader)) != sizeof(bmiHeader)) return ; int bmWidth = bmiHeader.biWidth; int bmHeight = bmiHeader.biHeight;

Tags: VC 源码: Bitmap



 文章评论

目前没有任何评论.

↓ 快抢占第1楼,发表你的评论和意见 ↓
 
发表你的评论
如果你想针对此文发表评论, 请填写下列表单:
姓名: * 必填
E-mail: 可选 (不会被公开)
反垃圾广告: 为了防止广告机器人自动发贴, 请计算下列表达式的值:
10 + 16 = * 必填
评论内容:
* 必填
你可以使用下列标签修饰文字:
[b] 文字 [/b]: 加粗文字
[quote] 文字 [/quote]: 引用文字

 

小辉程序员之路 建站于 1997 ◇ 做一名最好的开发者是我不变的理想……
Copyright(C) 1997-2009 XiaoHui.com   All rights reserved
声明:站内所有原创文字,未经许可,均可转载、复制。
转载时必须以链接形式注明作者和原始出处