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


C++ ImageManager::exists方法代码示例

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


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

示例1: load

	fcn::Image* GuiImageLoader::load(const std::string& filename, bool convertToDisplayFormat) {
		ImageManager* imgManager = ImageManager::instance();

		if(imgManager->exists(filename)) {
			return new GuiImage(imgManager->get(filename));
		}
		// load demanded image
		ImagePtr tmpimg = imgManager->load(filename);
		if(tmpimg->getWidth() >= ATLAS_SIZE || tmpimg->getHeight() >= ATLAS_SIZE) {
			return new GuiImage(tmpimg);
		}
		// look for a place for an image of given size
		AtlasBlock* block = m_atlasbook->getBlock(tmpimg->getWidth(), tmpimg->getHeight());

		// if it can't fit, we need to add new 'page'
		if(block->page >= m_atlases.size()) {
			m_atlases.push_back(imgManager->loadBlank(ATLAS_SIZE, ATLAS_SIZE));

			// because we gonna update texture on-the fly (via TexSubImage)
			// we cant really use compressed texture 
			RenderBackend* rb = RenderBackend::instance();
			bool prev = rb->isImageCompressingEnabled();
			rb->setImageCompressingEnabled(false);
			m_atlases[block->page]->forceLoadInternal();
			rb->setImageCompressingEnabled(prev);
		}
		
		// update atlas page with given image
		m_atlases[block->page]->copySubimage(block->left, block->top, tmpimg);
	
		// we dont really need this image anymore 
		tmpimg->free();
		imgManager->remove(tmpimg);

		// create shared image and return it
		ImagePtr img = imgManager->create(filename);
		Rect region(block->left, block->top, block->getWidth(), block->getHeight());
		img->useSharedImage(m_atlases[block->page], region);

		return new GuiImage(img);
	}
开发者ID:Creepinevil,项目名称:fifengine,代码行数:41,代码来源:gui_imageloader.cpp


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