MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / LoadImage

Function LoadImage

deps/LLGL/tests/Test_Image.cpp:18–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16
17
18LLGL::Image LoadImage(const std::string& filename, const LLGL::ImageFormat format = LLGL::ImageFormat::RGB)
19{
20 int requiredComp = static_cast<int>(LLGL::ImageFormatSize(format));
21
22 int w = 0, h = 0, comp = 0;
23 auto buf = stbi_load(filename.c_str(), &w, &h, &comp, requiredComp);
24
25 LLGL::Image img
26 {
27 LLGL::Extent3D { static_cast<std::uint32_t>(w), static_cast<std::uint32_t>(h), 1 },
28 format,
29 LLGL::DataType::UInt8
30 };
31
32 ::memcpy(img.GetData(), buf, img.GetDataSize());
33
34 stbi_image_free(buf);
35
36 return img;
37}
38
39void SaveImagePNG(const LLGL::Image& img, const std::string& filename, std::uint32_t slice = 0)
40{

Callers 4

Test_PixelOperationsFunction · 0.85
Test_BlitFunction · 0.85
Test_ResizeFunction · 0.85
LoadTextureArrayMethod · 0.85

Calls 6

stbi_loadFunction · 0.85
memcpyFunction · 0.85
stbi_image_freeFunction · 0.85
c_strMethod · 0.80
GetDataSizeMethod · 0.80
GetDataMethod · 0.45

Tested by

no test coverage detected