| 16 | |
| 17 | |
| 18 | LLGL::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 | |
| 39 | void SaveImagePNG(const LLGL::Image& img, const std::string& filename, std::uint32_t slice = 0) |
| 40 | { |
no test coverage detected