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


C++ ofFile::getFileName方法代码示例

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


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

示例1: processFile

//--------------------------------------------------------------
void ofApp::processFile(ofFile & file) {
	cout << file.getAbsolutePath() << endl;
	auto extension = ofToLower(file.getExtension());
	cout << extension << endl;
	if (extension == "jpg" || extension == "jpeg" || extension == "png") {
		ofImage loader;
		ofLogNotice("ofApp::dragEvent") << "loading " << file.getFileName() << " #" << decoder.getFrame();
		loader.loadImage(file);
		ofLogNotice("ofApp::dragEvent") << "adding " << file.getFileName();
		decoder << loader;
	} else if (extension == "sl") {
		this->decoder.loadDataSet(file.getAbsolutePath());
	}
}
开发者ID:elliotwoods,项目名称:Workshops.DigitalEmulsion,代码行数:15,代码来源:ofApp.cpp

示例2: CreateImage

// Create the clusters out of the image
ImgTexture ImgTextureFactory::CreateImage(const ofFile& inImageFile, const ofFile& inClusterFile)
{
	std::cout << "\nCreating Image: " << inImageFile.getFileName() << "\n";

	std::cout << "\nCreating Clustered Image: " << inClusterFile.getFileName() << "\n";

	// First create an image out of the incoming file, this can have any format
	ofImage image;
	image.loadImage(inImageFile);
	assert(image.isAllocated());

	// Load our clustered image in a pixel buffer
	ofPixels clustered_pix;
	ofLoadImage(clustered_pix, inClusterFile.getFileName());

	/*
	// Load our sample image in a pixel buffer
	ofPixels clustered_sample_pix;
	ofLoadImage(clustered_pix, inClusterFile.getFileName());
	*/

	// Now create our clustered image, this needs to be of a type (rgba, 8bc)
	assert(clustered_pix.isAllocated());
	assert(clustered_pix.getImageType() == OF_IMAGE_COLOR_ALPHA);
	assert(clustered_pix.getBitsPerPixel() == 32);

	// Will hold the final amount of clusters
	int cluster_counter = 0;

	// Used for storing the color value
	std::vector<BYTE>			colors;
	std::vector<int>			color_refs;

	// Now get the pixels and iterate over them
	// We sample how many clusters there are in the image,
	// The colors that belong to that cluster and how many times that color appears in the image
	BYTE* pixels = clustered_pix.getPixels();
	for (int x=0; x < clustered_pix.getWidth(); x++)
	{
		for(int y=0; y < clustered_pix.getHeight(); y++)
		{
			// Get the current read pos and sample color
			int read_pos = ((y*clustered_pix.getWidth())+ x) * 4;

			// Make sure alpha is not 0
			if(pixels[read_pos+3] < 2)
				continue;

			BYTE color = pixels[read_pos];

			// See if it's in the colors array, if not add
			bool	already_present = false;
			int		color_counter = 0;
			for(std::vector<BYTE>::iterator it = colors.begin(); it != colors.end(); ++it) 
			{
				// Get the color and sample within a range
				BYTE p_color = *it;
				if(!(color > *it+2) && !(color < *it-2))
				{
					already_present = true;
					(color_refs[color_counter])++;
					break;
				}

				// Increment color counter
				color_counter++;
			}

			if(!already_present)
			{
				colors.push_back(color);
				color_refs.push_back(1);
				cluster_counter++;
			}
		}
	}

	// Now delete the clusters that don't have enough pixels
	std::vector<BYTE> final_color_set;
	int counter = 0;
	int fclusters = 0;
	for(std::vector<int>::iterator it = color_refs.begin(); it != color_refs.end(); ++it)
	{
		if(*it >= MIN_CLUSTER_PIXEL_COUNT)
		{
			final_color_set.push_back(colors[counter]);
			fclusters++;
		}
		counter++;
	}

	// Sort the remaining ones based on color
	vector<BYTE>::iterator it;
	sort(final_color_set.begin(), final_color_set.end());

	// Return a new texture that holds the image and clusters
	return ImgTexture(image, clustered_pix, fclusters, final_color_set);
}
开发者ID:cklosters,项目名称:MikoVJ,代码行数:99,代码来源:ImgTextureFactory.cpp


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