进一步补充详细注释
This commit is contained in:
@@ -20,11 +20,13 @@ using namespace Gdiplus;
|
||||
*/
|
||||
static Bitmap* TryLoadBitmap(const std::wstring& path)
|
||||
{
|
||||
// 空路径和不存在的文件不交给 GDI+,减少无效加载开销。
|
||||
if (path.empty() || !FileExists(path))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// GDI+ 返回对象后仍需检查状态,失败对象要立即释放。
|
||||
Bitmap* loadedImage = Bitmap::FromFile(path.c_str(), FALSE);
|
||||
if (loadedImage != nullptr && loadedImage->GetLastStatus() == Ok)
|
||||
{
|
||||
@@ -65,6 +67,7 @@ Bitmap* LoadBackgroundImage()
|
||||
static Bitmap* backgroundImage = nullptr;
|
||||
static bool attempted = false;
|
||||
|
||||
// 背景图只查找一次,失败后也记住结果,避免每帧重复访问磁盘。
|
||||
if (!attempted)
|
||||
{
|
||||
attempted = true;
|
||||
@@ -110,6 +113,7 @@ Bitmap* LoadCreditImage(int index)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// 每张致谢图单独缓存,只有首次进入对应页时才加载。
|
||||
if (!attempted[index])
|
||||
{
|
||||
attempted[index] = true;
|
||||
|
||||
Reference in New Issue
Block a user