如何从文件中装入BITMAP图形?

happyboy007 2001-12-30 04:46:12
在对话框中,加入了一个图片框,但是为了方便修改,图象放在了bmp文件中,如何将图片框动态设置图象?EMAIL 为 happyboy007@163.net.多谢多谢!
...全文
184 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
happyboy007 2002-01-07
  • 打赏
  • 举报
回复
各位大佬,不是要显示一副bmp图,而是将一个bmp图与PICTURE控件绑定,这样需要的时候,仅仅显示picture控件即可
hujun614 2002-01-04
  • 打赏
  • 举报
回复
改为:
CStatic m_LOGOPICTURE;
m_LOGOPICTURE.SetBitmap( NULL,LoadImage(NULL,"Forset.bmp", IMAGE_BITMAP, x, y, LR_LOADFROMFILE));
m_LOGOPICTURE.ShowWindow(SW_SHOW);
hujun614 2002-01-04
  • 打赏
  • 举报
回复
LoadImage
The LoadImage function loads an icon, cursor, or bitmap.

HANDLE LoadImage(
HINSTANCE hinst, // handle of the instance containing the image
LPCTSTR lpszName, // name or identifier of image
UINT uType, // type of image
int cxDesired, // desired width
int cyDesired, // desired height
UINT fuLoad // load flags
);

LR_LOADFROMFILE Loads the image from the file specified by the lpszName parameter. If this flag is not specified, lpszName is the name of the resource

happyboy007 2002-01-04
  • 打赏
  • 举报
回复
改为:
CStatic m_LOGOPICTURE;
m_LOGOPICTURE.SetBitmap( NULL,LoadImage("Forset.bmp", IMAGE_BITMAP, x, y, LR_LOADFROMFILE));
m_LOGOPICTURE.ShowWindow(SW_SHOW);
SetBitmap的参数又不对了,大虾们请了请了
gwada 2002-01-04
  • 打赏
  • 举报
回复
少了句柄
happyboy007 2002-01-04
  • 打赏
  • 举报
回复
大哥,报错了。如下:
error C2660: 'LoadImageA' : function does not take 5 parameters
happyboy007 2002-01-04
  • 打赏
  • 举报
回复
hujun614(胡均):
CStatic::SetBitmap
HBITMAP SetBitmap( HBITMAP hBitmap );
参数不对呀

oyf888 2002-01-04
  • 打赏
  • 举报
回复
我KAO,就这么点事还讨论这多?
lsyljn 2002-01-04
  • 打赏
  • 举报
回复
给你一个原代码:

void CDialog8View::DispBmp(CString FileName,CDC *pDC)
{
CFile file;
if(!file.Open(FileName,CFile::modeRead|CFile::shareDenyNone))
return;

WORD bfType;
DWORD bfSize;
file.Read(&bfType,sizeof(WORD));
file.Read(&bfSize,sizeof(DWORD));
file.Seek(2*sizeof(WORD),CFile::current);
DWORD bf0fBits;
file.Read(&bf0fBits,sizeof(DWORD));
int size=bf0fBits-14;
LPBITMAPINFO lpbitmapinfo;
lpbitmapinfo=(LPBITMAPINFO) new BYTE[size];
file.Seek(14,CFile::begin);
file.ReadHuge(lpbitmapinfo,size);
LPVOID pbitsrc;
pbitsrc=(LPVOID) new char[bfSize-bf0fBits];
if(pbitsrc==NULL)
{
delete lpbitmapinfo;
return;
}
file.ReadHuge(pbitsrc,bfSize-bf0fBits);
file.Close();

CRect arry;
GetClientRect(&arry);
HDRAWDIB hdd= ::DrawDibOpen();
::DrawDibBegin(hdd,pDC->m_hDC,lpbitmapinfo->bmiHeader.biWidth,
lpbitmapinfo->bmiHeader.biHeight,&lpbitmapinfo->bmiHeader,
lpbitmapinfo->bmiHeader.biWidth,
lpbitmapinfo->bmiHeader.biHeight,DDF_ANIMATE);

::DrawDibDraw(hdd,pDC->m_hDC,
10,//(arry.right - lpbitmapinfo->bmiHeader.biWidth)/2,
10,//(arry.bottom - lpbitmapinfo->bmiHeader.biHeight)/2,
lpbitmapinfo->bmiHeader.biWidth,
lpbitmapinfo->bmiHeader.biHeight,
&lpbitmapinfo->bmiHeader,
pbitsrc,0,0,
lpbitmapinfo->bmiHeader.biWidth,
lpbitmapinfo->bmiHeader.biHeight,
DDF_SAME_DRAW|DDF_SAME_HDC);

::DrawDibClose(hdd);
delete lpbitmapinfo;
delete pbitsrc;
}
a_kun 2001-12-31
  • 打赏
  • 举报
回复
shit!
告诉你了用LoadImage(szFileName, IMAGE_BITMAP, x, y, LR_LOADFROMFILE);

CStatic m_LOGOPICTURE;
m_LOGOPICTURE.SetBitmap(LoadImage("Forset.bmp", IMAGE_BITMAP, x, y, LR_LOADFROMFILE));
m_LOGOPICTURE.ShowWindow(SW_SHOW);
happyboy007 2001-12-30
  • 打赏
  • 举报
回复
CStatic m_LOGOPICTURE;
m_LOGOPICTURE.SetBitmap(::LoadBitmap(NULL,"Forset.bmp"));
m_LOGOPICTURE.ShowWindow(SW_SHOW);
没有反应,请继续指点
lihanbing 2001-12-30
  • 打赏
  • 举报
回复

Set Picture1.Picture = LoadPicture("filename")
a_kun 2001-12-30
  • 打赏
  • 举报
回复
LoadImage(szFileName, IMAGE_BITMAP, x, y, LR_LOADFROMFILE);

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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