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


C++ ImageLoader::WriteBinary方法代码示例

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


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

示例1: TextureProcessorMain


//.........这里部分代码省略.........
		}
	}

	string extension = filename.substr(filename.find(".") + 1);

	ImageLoader* loader = NULL;

	if (extension == "jpg" || extension == "jpeg")
	{
		loader = new JpegLoader();
	}
	else if (extension == "png")
	{
		loader = new PngLoader();
	}
	else if (extension == "bmp")
	{
		loader = new BmpLoader();
	}
	

	
	/*ilInit();

	ilEnable(IL_FILE_OVERWRITE);

	ilEnable(IL_ORIGIN_SET);
	ilSetInteger(IL_ORIGIN_MODE, IL_ORIGIN_UPPER_LEFT); */

	auto startLoad = std::chrono::high_resolution_clock::now();

	loader->Load(filename, reverseChannels == true ? ImageLoader::PixelChannelOrder::ORDER_BGR : ImageLoader::PixelChannelOrder::ORDER_RGB);

	if (flipVertically)
		loader->FlipVertically();


	auto endLoad = std::chrono::high_resolution_clock::now();

	long long  timeLoad = std::chrono::duration_cast<std::chrono::milliseconds>(endLoad - startLoad).count();

	//TextureLoader loader = TextureLoader(filename.c_str());
	
	//std::cout << "timeLoad : " << timeLoad << "\n";

	//loader.SetTextureFormat(texFormat);

	auto startMip = std::chrono::high_resolution_clock::now();

	if(generateMipmaps)
		loader->GenerateMipmaps();



	auto endMip = std::chrono::high_resolution_clock::now();

	long long  timeMip = std::chrono::duration_cast<std::chrono::milliseconds>(endMip - startMip).count();

//	std::cout << "timeMip : " << timeMip << "\n";

	if (!useMemory)
	{
		// Texture loaded, now write a binary file.
		filename = strtok((char *)filename.c_str(), ".");		// Remove the extension.
		char* extension = strtok(NULL, ".");

		// Get the new filename with extension .bbt 
		filename = strtok((char*)filename.c_str(), ".");		// Remove the extension.
		filename += ".bbt";

		loader->WriteBinary(filename.c_str(), generateMipmaps);

		delete loader;
	}
	else // Memory.
	{
		/*auto startMem = std::chrono::high_resolution_clock::now();

		int totalSize = jpegLoader->GetTotalSizeToWrite();

		char* memory = AllocateMem(totalSize);
		
		jpegLoader->WriteMemory(memory, generateMipmaps);

		auto endMem = std::chrono::high_resolution_clock::now();

		auto timeMem = std::chrono::duration_cast<std::chrono::milliseconds>(endMem - startMem).count();

		auto end = std::chrono::high_resolution_clock::now();

		auto time = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count(); 

		SetBinary(memory);

		return memory; */
		return loader;
	}

	return 0;
}
开发者ID:banex19,项目名称:blondengine,代码行数:101,代码来源:BinaryTextureProcessor.cpp


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