怎样读取本地路径下的所有图片(bmp),在MFC上有按钮“”上一张”和“下一张”点一下就切换下一张,萌新求大佬指点!
直接看这个完整的例子:https://download.csdn.net/download/ipqftjb/6462093
如果没有积分下载,采纳后留下邮箱,帮你下。
以获取D:\test目录下所有bmp文件路径为例
void BrowseCurrentAllFile(CString strDir)
{
if (strDir == _T(""))
{
return;
}
else
{
if (strDir.Right(1) != _T("\"))
strDir += L"\";
strDir = strDir + _T("*.bmp");
}
CFileFind finder;
CString strPath;
BOOL bWorking = finder.FindFile(strDir);
while (bWorking)
{
bWorking = finder.FindNextFile();
strPath = finder.GetFilePath();
if (finder.IsDirectory() && !finder.IsDots())
BrowseCurrentAllFile(strPath); //递归调用
else if (!finder.IsDirectory() && !finder.IsDots())
{
//strPath就是所要获取的文件路径
//m_List.AddString(strPath);
}
}
}
调用方式:
BrowseCurrentAllFile(_T("D:\test"));
可参考https://blog.csdn.net/u013088062/article/details/50499797
LoadImage()
HIBTMAP bitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),strFileName,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);