MCPcopy Create free account
hub / github.com/NazaraEngine/NazaraEngine / Load

Function Load

src/Nazara/Utility/Formats/STBLoader.cpp:57–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55 }
56
57 bool Load(Image* image, Stream& stream, const ImageParams& parameters)
58 {
59 // Je charge tout en RGBA8 et je converti ensuite via la méthode Convert
60 // Ceci à cause d'un bug de STB lorsqu'il s'agit de charger certaines images (ex: JPG) en "default"
61
62 int width, height, bpp;
63 UInt8* ptr = stbi_load_from_callbacks(&callbacks, &stream, &width, &height, &bpp, STBI_rgb_alpha);
64 if (!ptr)
65 {
66 NazaraError("Failed to load image: " + String(stbi_failure_reason()));
67 return false;
68 }
69
70 if (!image->Create(ImageType_2D, PixelFormatType_RGBA8, width, height, 1, (parameters.levelCount > 0) ? parameters.levelCount : 1))
71 {
72 NazaraError("Failed to create image");
73 stbi_image_free(ptr);
74
75 return false;
76 }
77
78 image->Update(ptr);
79 stbi_image_free(ptr);
80
81 if (parameters.loadFormat != PixelFormatType_Undefined)
82 image->Convert(parameters.loadFormat);
83
84 return true;
85 }
86 }
87
88 namespace Loaders

Callers

nothing calls this directly

Calls 4

ConvertMethod · 0.80
StringClass · 0.50
CreateMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected