首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

程序如何使用png图片?

2012-12-21 
程序怎么使用png图片????如题!!!!!!!!!!!!!!!!!1[最优解释]包含头文件:#include atlimage.h定义成员变量

程序怎么使用png图片????
如题!!!!!!!!!!!!!!!!!1
[最优解释]
包含头文件:#include <atlimage.h>
定义成员变量 CImage image;
在OnInitDialog()或OnInitUpdate()函数里面:
        char path[256];
GetCurrentDirectory(256,path);
CString filepath = path;
filepath += "\\res\\19.JPG";//加载图片的路径
image.Load(filepath);

在OnDraw()或OnPaint()函数里面:
HBITMAP hBitmap=image.Detach();
CBitmap bmp;
bmp.Attach(hBitmap);

CMainFrame* pframe = (CMainFrame*)AfxGetApp()->m_pMainWnd;
CImgTestView* pview = (CImgTestView*)pframe->GetActiveView();
CDC* pdc = pview->GetDC();
CDC memdc;
memdc.CreateCompatibleDC(pdc);
memdc.SelectObject(&bmp);
pdc->BitBlt(0,0,3000,3000,&memdc,0,0,SRCCOPY);


memdc.DeleteDC();
bmp.DeleteObject();
齐活儿
[其他解释]
Graphics   graphics(GetDC()-> m_hDC); 
Image   image(L"Your.png",   FALSE); 
graphics.DrawImage(&image,   10,10, 100, 100);//大小位置
[其他解释]
http://download.csdn.net/detail/haha_12345_haha/3275486
[其他解释]
VC 贴png 图片的多种方http://download.csdn.net/detail/chudesong/3756838#comment法
[其他解释]
CImage
[其他解释]

引用:
包含头文件:#include <atlimage.h>
定义成员变量 CImage image;
在OnInitDialog()或OnInitUpdate()函数里面:
        char path[256];
GetCurrentDirectory(256,path);
CString filepath = path;
filepath += "\\r……

VS2005以上的IDE,直接使用CImage是最简单的
[其他解释]
1楼代码正解.
[其他解释]
该回复于2012-11-22 11:33:19被管理员删除
[其他解释]
是给对话框做背景还是按钮的背景?对话框背景GDI可以  如果是按钮的要重写…………

热点排行