MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / getFaceFromCache

Function getFaceFromCache

launcher/SkinUtils.cpp:31–49  ·  view source on GitHub ↗

* Given a username, return a pixmap of the cached skin (if it exists), QPixmap() otherwise */

Source from the content-addressed store, hash-verified

29 * Given a username, return a pixmap of the cached skin (if it exists), QPixmap() otherwise
30 */
31QPixmap getFaceFromCache(QString username, int height, int width)
32{
33 QFile fskin(APPLICATION->metacache()->resolveEntry("skins", username + ".png")->getFullPath());
34
35 if (fskin.exists())
36 {
37 QPixmap skinTexture(fskin.fileName());
38 if(!skinTexture.isNull())
39 {
40 QPixmap skin = QPixmap(8, 8);
41 QPainter painter(&skin);
42 painter.drawPixmap(0, 0, skinTexture.copy(8, 8, 8, 8));
43 painter.drawPixmap(0, 0, skinTexture.copy(40, 8, 8, 8));
44 return skin.scaled(height, width, Qt::KeepAspectRatio);
45 }
46 }
47
48 return QPixmap();
49}
50}

Callers

nothing calls this directly

Calls 5

getFullPathMethod · 0.80
resolveEntryMethod · 0.80
metacacheMethod · 0.80
existsMethod · 0.80
copyMethod · 0.80

Tested by

no test coverage detected