Add new Lua function to query size of an image

This commit is contained in:
Alexander Bock
2025-12-08 20:21:36 +01:00
parent 6b20d114c8
commit add85f4c6d
3 changed files with 13 additions and 1 deletions

View File

@@ -1738,6 +1738,7 @@ scripting::LuaLibrary OpenSpaceEngine::luaLibrary() {
codegen::lua::RemoveTag,
codegen::lua::DownloadFile,
codegen::lua::CreateSingleColorImage,
codegen::lua::ImageSize,
codegen::lua::SaveBase64File,
codegen::lua::IsMaster,
codegen::lua::Version,

View File

@@ -34,6 +34,7 @@
#include <ghoul/filesystem/cachemanager.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/glm.h>
#include <ghoul/io/texture/texturereader.h>
#include <ghoul/io/texture/texturewriter.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/lua/lua_helper.h>
@@ -209,6 +210,16 @@ namespace {
return fileName;
}
/**
* This function returns the size in pixels of an image file.
*
* \param path The location of the image file for which the pixel size will be returned
* \return The size of the image in pixels
*/
[[codegen::luawrap]] glm::ivec2 imageSize(std::filesystem::path path) {
return ghoul::io::TextureReader::ref().imageSize(path);
}
/**
* This function takes a base64 encoded data string, decodes it and saves the resulting
* data to the provided filepath.