| 88 | } |
| 89 | |
| 90 | bool 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 | |
| 119 | bool TextureData::initFromRGBA(const unsigned char* dataRGBA, size_t width, size_t height) |
| 120 | { |
no test coverage detected