当前位置: 首页>>代码示例>>C++>>正文


C++ QFile::getch方法代码示例

本文整理汇总了C++中QFile::getch方法的典型用法代码示例。如果您正苦于以下问题:C++ QFile::getch方法的具体用法?C++ QFile::getch怎么用?C++ QFile::getch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QFile的用法示例。


在下文中一共展示了QFile::getch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: huedist

QValueVector<QColor> amaroK::readMood(const QString path)
{
	debug() << "MakeMood: Reading mood file " << path << endl;
	QString filebase = path;
	QValueVector<QColor> theArray;
	filebase.truncate(filebase.findRev('.'));
	filebase += ".mood";
	QString dotfilebase = filebase, homefilebase = filebase;
	dotfilebase.insert(filebase.findRev('/') + 1, '.');
	homefilebase.replace('/', ',');
	homefilebase = ::locateLocal("data", "amarok/moods/" + homefilebase);
	QFile mood;
	if(QFile::exists(filebase)) mood.setName(filebase);
	if(QFile::exists(dotfilebase)) mood.setName(dotfilebase);
	if(QFile::exists(homefilebase)) mood.setName(homefilebase);
	if(mood.name() != "" && mood.open(IO_ReadOnly))
	{
		int r, g, b, s = mood.size() / 3;
		debug() << "ReadMood: File opened. Proceeding to read contents... s=" << s << endl;
		QMemArray<int> huedist(360);
		int total = 0, mx = 0;
		for(int i = 0; i < 360; i++) huedist[i] = 0;
		theArray.resize(s);
		for(int i = 0; i < s; i++)
		{
			r = mood.getch();
			g = mood.getch();
			b = mood.getch();
			theArray[i] = QColor(CLAMP(0, r, 255), CLAMP(0, g, 255), CLAMP(0, b, 255), QColor::Rgb);
			int h, s, v;
			theArray[i].getHsv(&h, &s, &v);
			if(h < 0) h = 0; else h = h % 360;
			huedist[h]++;
			if(mx < huedist[h]) mx = huedist[h];
		}
		debug() << "ReadMood: File read. Maximum hue bin size = " <<  mx << endl;
		if(AmarokConfig::makeMoodier())
		{
			debug() << "ReadMood: Making moodier!" << endl;
			int threshold, rangeStart = 0, rangeDelta = 359, sat = 100, val = 100;
			switch(AmarokConfig::alterMood())
			{
				// Angry
				case 1: threshold = s / 360 * 9; rangeStart = 45; rangeDelta = -45; sat = 200; val = 100; break;
				// Frozen
				case 2: threshold = s / 360 * 1; rangeStart = 140; rangeDelta = 160; sat = 50; val = 100; break;
				// Happy
				default: threshold = s / 360 * 2; rangeStart = 0; rangeDelta = 359; sat = 150; val = 250;
			}
			debug() << "ReadMood: Appling filter t=" << threshold << ", rS=" << rangeStart << ", rD=" << rangeDelta << ", s=" << sat << "%, v=" << val << "%" << endl;
			for(int i = 0; i < 360; i++) if(huedist[i] > threshold) total++;
			debug() << "ReadMood: Total=" << total << endl;
			if(total < 360 && total > 0)
			{
				for(int i = 0, n = 0; i < 360; i++)
					huedist[i] = ((huedist[i] > threshold ? n++ : n) * rangeDelta / total + rangeStart) % 360;
				for(uint i = 0; i < theArray.size(); i++)
				{	int h, s, v;
					theArray[i].getHsv(&h, &s, &v);
					if(h < 0) h = 0; else h = h % 360;
					if(h > 359) debug() << "ReadMood: Bad hue in array[" << i << "]: " << h << endl;
					theArray[i].setHsv(CLAMP(0, huedist[h], 359), CLAMP(0, s * sat / 100, 255), CLAMP(0, v * val / 100, 255));
				}
			}
		}
	}
	debug() << "ReadMood: All done." << endl;
	return theArray;
}
开发者ID:tmarques,项目名称:waheela,代码行数:69,代码来源:moodbar.cpp


注:本文中的QFile::getch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。