MCPcopy Create free account
hub / github.com/DiscordMessenger/dm / SetImage

Method SetImage

src/windows/AvatarCache.cpp:55–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void AvatarCache::SetImage(const std::string& resource, HImage* him, bool hasAlpha)
56{
57 std::string id = MakeIdentifier(resource);
58
59 // Remove the least recently used bitmap until the maximum amount is loaded.
60 while (m_profileToBitmap.size() > MAX_BITMAPS_KEEP_LOADED)
61 {
62 if (!TrimBitmap())
63 break;
64 }
65
66 AgeBitmaps();
67
68 auto iter = m_profileToBitmap.find(id);
69 if (iter != m_profileToBitmap.end())
70 {
71 DeleteImageIfNeeded(iter->second.m_image);
72 iter->second.m_image = him;
73 iter->second.m_age = 0;
74 iter->second.m_bHasAlpha = hasAlpha;
75 return;
76 }
77
78 m_profileToBitmap[id] = BitmapObject(him, 0, hasAlpha);
79}
80
81ImagePlace AvatarCache::GetPlace(const std::string& resource)
82{

Callers 2

OnAttachmentFailedMethod · 0.80

Calls 4

BitmapObjectClass · 0.85
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected