⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 数据格式转换.txt

📁 图像处理学习的一些心得
💻 TXT
字号:
CString TimeToDisplay(int nTotalSecond)
{
	CString szTime;
	int		nHour, nMin, nSec;
	CString szHour, szMin, szSec;
	nHour = nTotalSecond/3600;
	nMin  = (nTotalSecond%3600)/60;
	nSec  = (nTotalSecond%3600)%60;;
	szHour.Format("%d",nHour);
	if(szHour.GetLength() < 2)
		szHour = "0" + szHour;
	szMin.Format("%d",nMin);
	if(szMin.GetLength() < 2)
		szMin = "0" + szMin;
	szSec.Format("%d",nSec);
	if(szSec.GetLength() < 2)
		szSec = "0" + szSec;
	szTime.Format("%s:%s:%s", szHour, szMin, szSec);
	return szTime;
}

int StringToInt(CString s)
{
	int nReturn = 0;
	char cc[10];
	wsprintf(cc, "%s", s);
	nReturn = atoi(cc);
	return nReturn;
}

CString IntToTime(int nTime, float fSample)
{
	CString sTime;
	nTime = nTime / fSample;
	int nHour, nMinute, nSecond;
	nHour	= nTime / 3600;
	nMinute = (nTime % 3600) / 60;
	nSecond = nTime % 60;
	if(nHour == 0)
		sTime.Format("00:%2d:%2d", nMinute, nSecond);
	else
		sTime.Format("%d:%2d:%2d", nHour, nMinute, nSecond);

	return sTime;
}

float StringToFloat(CString s)
{
	float fReturn = 0;
	char cc[10];
	wsprintf(cc, "%s", s);
	fReturn = atof(cc);
	return fReturn;
}

CTime StringToTime(CString s)
{
	int nYear, nMonth, nDay, nHour, nMinute, nSecond;
	CString ss;
	ss = s.Left(4);
	nYear = StringToInt(ss);

	ss = s.Mid(4,2);
	nMonth = StringToInt(ss);
	
	ss = s.Mid(6,2);
	nDay = StringToInt(ss);

	ss = s.Mid(8,2);
	nHour = StringToInt(ss);

	ss = s.Mid(10,2);
	nMinute = StringToInt(ss);

	ss = s.Mid(12,2);
	nSecond = StringToInt(ss);

	CTime t(nYear, nMonth, nDay, nHour, nMinute, nSecond);
	return t;
}

int	StreamToStringArray(LPSTREAM pStream, CStringArray& sArray)
{
	int		nCount = 0;
	ULONG	nLength;
	BYTE*	pBuf;
	CString	sz;
	pBuf = new BYTE[MAX_DATA_LENGTH];      
	pStream->Read(pBuf, MAX_DATA_LENGTH, &nLength);
    pBuf[nLength] = '\0';

    TRACE("%s\n", pBuf);
	sz.Format("%s",pBuf);
	sz.TrimLeft();
	sz.TrimRight();
		
	int		nPos = 0;
	CString	c;
	c = _T(' ');
	sArray.RemoveAll();

	nPos = sz.Find(c, 0);
	while((nPos != -1))
	{
		sArray.Add(sz.Left(nPos));
		nCount++;
		sz = sz.Right(sz.GetLength() - nPos - 1);
		sz.TrimLeft();
		nPos = sz.Find(c, 0);		
	}
	if(!sz.IsEmpty())
	{
		sArray.Add(sz);
		nCount++;
	}
	delete pBuf;
	return nCount;
}

//important to debug
int	StringArrayToStream(LPSTREAM pStream, CStringArray& sArray) 
{
	CString	s,c;
	c = _T(' ');
	char	szData[100]; 
	
	int		nCount = sArray.GetSize();
	for(int i = 0; i < nCount; i++)
	{
		s = sArray.GetAt(i);
		VERIFY(s.GetLength() < 100);
		wsprintf(szData,"%s%s", s, c);
		pStream->Write(szData,strlen(szData),NULL); 
	}
	
	return	nCount;
}

//判断目录、文件是否存在
BOOL IsFileExist(CString m_strPath,bool m_bIsFile)
{
	if(m_strPath.Right (1)=="\\")
		m_strPath=m_strPath.Left (m_strPath.GetLength ()-1);
	if(m_strPath.FindOneOf ("*?")!=-1)
		return FALSE;
	if(!m_bIsFile)
	{
		if(SetCurrentDirectory(m_strPath))
			return TRUE;
	}
	else
	{
		WIN32_FIND_DATA  fdata;
		HANDLE hf;
		hf=FindFirstFile(m_strPath,&fdata);
		if(hf==INVALID_HANDLE_VALUE)
			return FALSE;
		if(fdata.dwFileAttributes !=FILE_ATTRIBUTE_DIRECTORY)
			return TRUE;
		else
		{
			while(FindNextFile(hf,&fdata))
			{
				if(fdata.dwFileAttributes !=FILE_ATTRIBUTE_DIRECTORY)
					return TRUE;
			}
		}
	}
	return FALSE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -