Ejemplo n.º 1
0
	PixelBufferPtr ImageFile::load(const IODevicePtr &file, const std::string &type, bool srgb)
	{
		SetupDisplay::start();
		auto &types = *SetupDisplay::get_image_provider_factory_types();
		if (types.find(type) == types.end()) throw Exception("Unknown image provider type " + type);

		ImageFileType *factory = types[type];
		return factory->load(file, srgb);
	}
Ejemplo n.º 2
0
	PixelBufferPtr ImageFile::load(const std::string &filename, const std::string &type, bool srgb)
	{
		SetupDisplay::start();
		auto &types = *SetupDisplay::get_image_provider_factory_types();
		if (type != "")
		{
			if (types.find(type) == types.end()) throw Exception("Unknown image provider type " + type);

			ImageFileType *factory = types[type];
			return factory->load(filename, srgb);
		}

		// Determine file extension and use it to lookup type.
		std::string ext = FilePath::extension(filename);
		ext = Text::to_lower(ext);
		if (types.find(ext) == types.end()) throw Exception(std::string("Unknown image provider type ") + ext);

		ImageFileType *factory = types[ext];
		return factory->load(filename, srgb);
	}