shared_ptr<Gdiplus::Bitmap> ImageCache::LoadImageFile(const String& basepath, const String& filename)
	{
		URI uri = URI::Parse(filename);
		uri = URI::MakeAbsolute(basepath, uri);

		String newFilename = LibCC::StringToLower(uri.ToString());
		CacheMap::iterator it = m_cache.find(newFilename);
		if (it != m_cache.end())
			return it->second;

		ImagePtr image;
		if (uri.scheme == URI::SchemeFile)
		{
			image.reset(Gdiplus::Bitmap::FromFile(uri.path.c_str()));
		}
		else if (uri.scheme == URI::SchemeRes)
		{
			image.reset(BitmapFromResource(_Module.GetResourceInstance(), uri.path.c_str(), L"FILE"));
		}

		if (image)
			m_cache[newFilename] = image;

		return image;
	}
Exemple #2
0
// Determines the mime type of uri.
// Returns mime type or empty string if it can't be determined.
std::string GetMimeType(const URI& uri)
{
	std::string mimeType;
	// We don't need to free buffer.
	char* const buffer = gnome_vfs_get_mime_type(uri.ToString().c_str());
	if (buffer != 0)
		mimeType = buffer;
	return mimeType;
}
Exemple #3
0
void URI::Copy(const URI &uri)
{
    mWindowsNameConvert = uri.mWindowsNameConvert;
    Parse(uri.ToString());
}