MCPcopy Create free account
hub / github.com/Autodesk/Aurora / setImageFromFilePath

Method setImageFromFilePath

Libraries/Aurora/Source/SceneBase.cpp:202–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200}
201
202void SceneBase::setImageFromFilePath(
203 const Path& atPath, const string& filePath, bool forceLinear, bool isEnvironment)
204{
205 // Set file path to Aurora path if empty.
206 string imagePath = filePath;
207 if (imagePath.empty())
208 imagePath = atPath;
209
210 Aurora::ImageDescriptor imageDesc;
211 imageDesc.linearize = forceLinear;
212 imageDesc.isEnvironment = isEnvironment;
213
214 // Setup pixel data callback to get address and size from buffer from cache entry.
215 string pathToLoad = filePath;
216 imageDesc.getData = [this, forceLinear, pathToLoad](
217 Aurora::ImageData& dataOut, AllocateBufferFunction /* alloc*/) {
218 shared_ptr<ImageAsset> pImageAsset;
219
220 // Lookup in loaded images map, return
221 auto iter = _loadedImages.find(pathToLoad);
222 if (iter != _loadedImages.end())
223 {
224 pImageAsset = iter->second;
225 }
226 else
227 {
228 pImageAsset = rendererBase()->assetManager()->acquireImage(pathToLoad);
229
230 if (!pImageAsset)
231 {
232 pImageAsset = _pErrorImageData;
233 AU_ERROR("Failed to load image %s", pathToLoad.c_str());
234 }
235 _loadedImages[pathToLoad] = pImageAsset;
236 }
237
238 // Fill in output data.
239 dataOut.format = pImageAsset->data.format;
240 dataOut.dimensions = { pImageAsset->data.width, pImageAsset->data.height };
241 dataOut.pPixelBuffer = pImageAsset->pixels.get();
242 dataOut.bufferSize = pImageAsset->sizeBytes;
243
244 // Override the linearize value with the one inferred from the image file, unless client
245 // passed forceLinear flag.
246 dataOut.overrideLinearize = !forceLinear;
247 dataOut.linearize = pImageAsset->data.linearize;
248
249 return true;
250 };
251 imageDesc.updateComplete = [this, pathToLoad]() { _loadedImages.erase(pathToLoad); };
252
253 setImageDescriptor(atPath, imageDesc);
254}
255
256void SceneBase::setMaterialType(
257 const Path& atPath, const std::string& materialType, const std::string& document)

Callers 2

getImageMethod · 0.80

Calls 4

emptyMethod · 0.45
endMethod · 0.45
acquireImageMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected