MFC中的图像处理 [英] Image handling in MFC

查看:78
本文介绍了MFC中的图像处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建MFC应用程序以创建图片查看器软件.我可以选择该文件夹并一口气显示其中的所有图像.我要实现暂停,停止,下一个,上一个选项.到目前为止,当图像运行时,其余按钮甚至菜单都被禁用.
希望我能解决这个问题.
我正在使用Visual Studio2008.
谁能帮帮我.

[edit]

抱歉,我经过了这么长时间才回来.感谢您对我的问题的关注.我在这里添加代码以供审核.

  void  CCA_ToolDlg :: OnBnClickedPlay()
{
处理hFind;
字符串strPrefix;
WIN32_FIND_DATA FindData;
字符模式[ 150 ];
sprintf(pattern," ,ImagePath);
sprintf(ImagePath," ,ImagePath);
hFind = FindFirstFile(pattern,& FindData);
字符 *文件名;
filename =(字符 *)calloc( 2000  sizeof (字符));

{
strPrefix =字符串(ImagePath);
strPrefix + = FindData.cFileName;
sprintf(filename," ,strPrefix.c_str());
m_picCtrl.Load(CString(_T(文件名)));
}  while (FindNextFile(hFind,& FindData));
FindClose(hFind);
免费(文件名);
} 


当我单击播放按钮时,这就是功能.
现在,当我进入do循环时,我的所有对话框都不会响应任何用户输入.我正在使用PictureCrtl显示图像.
因此,当此功能运行时,我该如何处理其他按钮功能.
谢谢大家.
[/edit]

解决方案

嗯,您的问题很简单,这是解决方法

您无法使用对话框控件的原因是罪魁祸首"的do-while循环,它执行得非常快,并且实际上会挂起您的程序,直到完成查找最后一个文件并显示其属性为止.

您需要在单独的线程中编写循环,并休眠几秒钟,具体取决于您希望一张图片在屏幕上停留多长时间,届时您的主对话框将响应您的鼠标单击或任何其他事件.

I am trying to create a MFC application to create picture viewer software. I am able to select the folder and display all the images in it at a stretch. I want to implement pause, stop, next, previous options to it. As of now, when the images are running rest of the buttons and even the menu is disabled.
I hope I made the problem clear.
I am using Visual studio 2008.
Can anyone help me out.

[edit]
Hi there,
I am sorry for coming back after so much delay. Thanks for the interest in my question. I am adding code here for review.

void CCA_ToolDlg::OnBnClickedPlay()
{
	HANDLE hFind;
	string strPrefix;
	WIN32_FIND_DATA FindData;
	char pattern[150];
	sprintf(pattern, "%s\\*.jpg", ImagePath);
	sprintf(ImagePath, "%s\\", ImagePath);
	hFind = FindFirstFile(pattern, &FindData);
	char *filename;
	filename = (char *)calloc(2000,sizeof(char));
	do
	{		
		strPrefix = string(ImagePath);
		strPrefix += FindData.cFileName;
		sprintf(filename,"%s",strPrefix.c_str());
		m_picCtrl.Load(CString(_T(filename)));
	}while(FindNextFile(hFind, &FindData));
	FindClose(hFind);
	free(filename);
}


This is the function when i click on play button.
Now, when i am inside the do loop, All my dialog doesnt respond to any user inputs. I am using PictureCrtl to display the images.
So, how I can handle other button functions when this function is running.
Thanks all.
[/edit]

解决方案

hmm well, your problem is very simple, here is the solution

the reason you can''t use the controls of the dialog is the culprit do-while loop, its executing very fast and literally hang your program until it finishes to find the last file and display its attribute.

you need to write the loop in a separate thread with a sleep of few seconds depending on how long you want one picture to stay on the screen and by that time your main dialog will respond to your mouse click or any other events.


这篇关于MFC中的图像处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆