MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / initImageFromMemory

Method initImageFromMemory

src/server/gui/core/resources/TextureData.cpp:90–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90bool TextureData::initImageFromMemory(const unsigned char* fileData, size_t length)
91{
92 size_t width, height;
93
94 //LOG(LogInfo) << "mDataRGBA: initImageFromMemory for path: " << mPath;
95
96 // If already initialised then don't read again
97 {
98 std::unique_lock<std::mutex> lock(mMutex);
99 if (mDataRGBA)
100 return true;
101 }
102
103 std::vector<unsigned char> imageRGBA = ImageIO::loadFromMemoryRGBA32((const unsigned char*)(fileData), length, width, height);
104 if (imageRGBA.size() == 0)
105 {
106 LOG(LogError) << "Could not initialize texture from memory, invalid data! (file path: "
107 << mPath << ", data ptr: " << (size_t)fileData << ", reported size: "
108 << length << ")";
109 return false;
110 }
111
112 mSourceWidth = (float) width;
113 mSourceHeight = (float) height;
114 mScalable = false;
115
116 return initFromRGBA(imageRGBA.data(), width, height);
117}
118
119bool TextureData::initFromRGBA(const unsigned char* dataRGBA, size_t width, size_t height)
120{

Callers 1

initFromMemoryMethod · 0.80

Calls 2

dataMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected