Beispiel #1
0
ImageBase* AddCacheImage(const CMString& file, int index)
{
	CMString tmpfile(file); tmpfile.AppendFormat(_T("#%d"), index);
	unsigned id = mir_hash(tmpfile.c_str(), tmpfile.GetLength() * sizeof(TCHAR));

	WaitForSingleObject(g_hMutexIm, 3000);

	ImageBase srch(id);
	ImageBase *img = g_imagecache.find(&srch);
	if (img == NULL) {
		int ind = file.ReverseFind('.');
		if (ind == -1)
			return NULL;

		CMString ext = file.Mid(ind+1);
		ext.MakeLower();
		if (ext == _T("dll") || ext == _T("exe"))
			img = opt.HQScaling ? (ImageBase*)new ImageType(id, file, index, icoDll) : (ImageBase*)new IconType(id, file, index, icoDll);
		else if (ext == _T("ico"))
			img = opt.HQScaling ? (ImageBase*)new ImageType(id, file, 0, icoFile) : (ImageBase*)new IconType(id, file, 0, icoFile);
		else if (ext == _T("icl"))
			img = opt.HQScaling ? (ImageBase*)new ImageType(id, file, index, icoIcl) : (ImageBase*)new IconType(id, file, index, icoIcl);
		else if (ext == _T("gif"))
			img = new ImageType(id, file, NULL);
		else if (fei == NULL || ext == _T("tif") || ext == _T("tiff"))
			img = new ImageType(id, file, NULL);
		else
			img = opt.HQScaling ? (ImageBase*)new ImageType(id, file, NULL) : (ImageBase*)new ImageFType(id, file);

		g_imagecache.insert(img);

		if (timerId == 0) {
			timerId = 0xffffffff;
			CallFunctionAsync(sttMainThreadCallback, NULL);
		}
	}
	else img->AddRef();

	ReleaseMutex(g_hMutexIm);

	return img;
}