菜鸟提问:怎样从HBITMAP获得BMP的尺寸?(SDK)

thisisjjjj 2003-09-11 08:54:52
用LoadBitmap获得HBITMAP类型的handle,怎么才能得到BMP的尺寸信息?
我记得尺寸信息记录在一个BITMAPINFO结构里的,但是如何提取呢?
...全文
340 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
thisisjjjj 2003-09-11
  • 打赏
  • 举报
回复
GOOD!

结帖
thisisjjjj 2003-09-11
  • 打赏
  • 举报
回复
好象行的通哎,我试试
lshadow 2003-09-11
  • 打赏
  • 举报
回复
BITMAP bm;
HBITMAP hBitmap;
GetObject(hBitmap, sizeof(BITMAP), (LPBYTE)&bm);

这样ok了吧
thisisjjjj 2003-09-11
  • 打赏
  • 举报
回复
恩,怎么得到呢?
lshadow 2003-09-11
  • 打赏
  • 举报
回复
BITMAP结构里有尺寸信息
thisisjjjj 2003-09-11
  • 打赏
  • 举报
回复
我要用SDK完成,不要MFC
lshadow 2003-09-11
  • 打赏
  • 举报
回复
用CBitmap就很简单啊,
有CBitmap::GetBitmap
thisisjjjj 2003-09-11
  • 打赏
  • 举报
回复
晕死了
我要获取尺寸信息啊
干吗又要去设置它?
lshadow 2003-09-11
  • 打赏
  • 举报
回复
就是说如果没有 SetBitmapDimensionEx 过的话,返回值就是0
lshadow 2003-09-11
  • 打赏
  • 举报
回复
GetBitmapDimensionEx
The GetBitmapDimensionEx function retrieves the dimensions of a bitmap. The retrieved dimensions must have been set by the SetBitmapDimensionEx function.

BOOL GetBitmapDimensionEx(
HBITMAP hBitmap, // handle to bitmap
LPSIZE lpDimension // dimensions
);
Parameters
hBitmap
[in] Handle to the bitmap.
lpDimension
[out] Pointer to a SIZE structure to receive the bitmap dimensions.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.

Windows NT/ 2000: To get extended error information, call GetLastError.

Remarks
The function returns a data structure that contains fields for the height and width of the bitmap, in .01-mm units. If those dimensions have not yet been set, the structure that is returned will have zeroes in those fields
thisisjjjj 2003-09-11
  • 打赏
  • 举报
回复
返回值两个都是0

……
HBITMAP hBitmap = LoadBitmap(......);
……
SIZE SizeOfBitmap;
GetBitmapDimensionEx(hBitmap, &SizeOfBitmap);
……

结果:
SizeOfBitmap.cx = 0
SizeOfBitmap.cy = 0
duqiang2050 2003-09-11
  • 打赏
  • 举报
回复
BOOL GetBitmapDimensionEx(
HBITMAP hBitmap, // handle to bitmap
LPSIZE lpDimension // address of structure receiving dimensions
);

lpDimension是返回值
lpDimension->cx
lpDimension->cy
就是尺寸
thisisjjjj 2003-09-11
  • 打赏
  • 举报
回复
GetBitmapDimensionEx只对DDB有效吧?
具体如何使用,能详细说一下么?
duqiang2050 2003-09-11
  • 打赏
  • 举报
回复
GetBitmapDimensionEx

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧