VC中,MFC编程如何插入位图图像

nicolas08 2007-12-19 12:41:37
VC中,MFC编程如何插入位图图像
VC中用AppWizard生成程序框架后,如何实现编译后在“文件”下拉菜单“打开”选项自由选择位图图像读入并显示呢?不是在resource里面插入位图图像,位图文件整合在程序中那种?
谢谢!
...全文
451 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
菜牛 2008-01-31
  • 打赏
  • 举报
回复
MSDN中的例子DIBLOOK。
hud888 2008-01-31
  • 打赏
  • 举报
回复
不知这里回复时能不能传附件,我有完整的例子。
hndxh3000 2008-01-31
  • 打赏
  • 举报
回复
使用opencv,有个函数cvLoadImage( , );
可直接装载IPP库的各种格式图象文件,自动按文件扩展名进行识别
低头路过 2008-01-31
  • 打赏
  • 举报
回复
楼上正解
kittyhuaner 2007-12-21
  • 打赏
  • 举报
回复
LoadImage Function

--------------------------------------------------------------------------------

Loads an icon, cursor, animated cursor, or bitmap.

Syntax

HANDLE LoadImage( HINSTANCE hinst,
LPCTSTR lpszName,
UINT uType,
int cxDesired,
int cyDesired,
UINT fuLoad
);
#include <windows.h>
#include <stdio.h>

char *strFileName[]=
{
"d:\\1.bmp",
"d:\\4.bmp",
"d:\\8.bmp",
"d:\\16.bmp",
"d:\\24.bmp",
"d:\\32.bmp"
};

void DumpInfo(char *szFileName,UINT uType) {
HBITMAP
hBitmap=(HBITMAP)LoadImageA(NULL,szFileName,IMAGE_BITMAP,0,0,uType);
BITMAP bm;
GetObject(hBitmap,sizeof(bm),&bm);
printf("%s\t%d\n",szFileName,bm.bmBitsPixel);
}

int main()
{

printf("Flag=LR_LOADFROMFILE\n");
for(int i=0;i<6;i++)
{
DumpInfo(strFileName[i],LR_LOADFROMFILE);
}

printf("Flag=LR_LOADFROMFILE|LR_CREATEDIBSECTION\n");
for(int i=0;i<6;i++)
{
DumpInfo(strFileName[i],LR_LOADFROMFILE|LR_CREATEDIBSECTION);
}
return 0;
}
kittyhuaner 2007-12-19
  • 打赏
  • 举报
回复
MFC中没直接显示.bmp文件的函数。
如果你要打开位图显示在窗口上,要先了解一下.bmp文件的格式,读取.bmp文件中相关信息,再用windows的函数把图片显示出来。
参考CBitmap

yuyunliuhen 2007-12-19
  • 打赏
  • 举报
回复
应该有具体的函数
在MSDN搜索LoadBitmap的用法看看。


HBITMAP LoadBitmap(
HINSTANCE hInstance,
LPCTSTR lpBitmapName
);

This function loads the specified bitmap resource from the executable file for a module.

hInstance
[in] Handle to the instance of the module for which the executable file contains the bitmap that you want to load.
lpBitmapName
[in] Long pointer to a null-terminated string that contains the name of the bitmap resource that you want to load.
Alternatively, this parameter can consist of the resource identifier in the low-order word and zero in the high-order word.

The MAKEINTRESOURCE macro can be used to create this value.

The maximum value for the resource identifier is 32000.

19,468

社区成员

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

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