diff --git a/CMakeLists.txt b/CMakeLists.txt index a079f96..7cd90a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,13 @@ option(PSAPI_BUILD_BENCHMARKS "Build the benchmarks associated with the Photosho option(PSAPI_BUILD_DOCS "Builds the documentation, requires some external installs which are documented in the README.md" OFF) option(PSAPI_BUILD_PYTHON "Build the python bindings associated with the PhotoshopAPI" OFF) + +if (PSAPI_BUILD_PYTHON) + # Link in the msvc runtime so that users dont need vcredist when using the python bindings + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +endif() + + # Build setup list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set (CMAKE_CXX_STANDARD 20) @@ -23,8 +30,7 @@ set (CMAKE_CXX_STANDARD 20) # Add the cmake/ folder so the FindSphinx module is found # -------------------------------------------------------------------------- set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) -# Link in the msvc runtime so that users dont have to have it dynamically loaded -set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + # Add thirdparty libraries # -------------------------------------------------------------------------- diff --git a/PhotoshopAPI/src/LayeredFile/LayeredFile.h b/PhotoshopAPI/src/LayeredFile/LayeredFile.h index 2388ca7..48b060d 100644 --- a/PhotoshopAPI/src/LayeredFile/LayeredFile.h +++ b/PhotoshopAPI/src/LayeredFile/LayeredFile.h @@ -496,7 +496,7 @@ struct LayeredFile { /// The root layers in the file, they may contain multiple levels of sub-layers std::vector>> m_Layers; - + /// The ICC Profile associated with the file, this may be empty in which case there will be no colour /// profile associated with the file ICCProfile m_ICCProfile; @@ -508,13 +508,13 @@ struct LayeredFile Enum::BitDepth m_BitDepth = Enum::BitDepth::BD_8; /// The color mode of the file. Currently supports RGB only. - Enum::ColorMode m_ColorMode = Enum::ColorMode::RGB; + Enum::ColorMode m_ColorMode = Enum::ColorMode::RGB; /// The width of the file in pixels. Can be up to 30,000 for PSD and up to 300,000 for PSB - uint64_t m_Width = 0u; + uint64_t m_Width = 1u; /// The height of the file in pixels. Can be up to 30,000 for PSD and up to 300,000 for PSB - uint64_t m_Height = 0u; + uint64_t m_Height = 1u; LayeredFile() = default; @@ -557,6 +557,15 @@ struct LayeredFile /// \param height The height of the file in pixels. LayeredFile(Enum::ColorMode colorMode, uint64_t width, uint64_t height) requires std::same_as { + if (width < 1 || width > 300000) + { + PSAPI_LOG_ERROR("LayeredFile", "Invalid width for Photoshop file provided, must be in the range of 1-300,000 pixels. Got: %" PRIu64 " pixels", width); + } + if (height < 1 || height > 300000) + { + PSAPI_LOG_ERROR("LayeredFile", "Invalid height for Photoshop file provided, must be in the range of 1-300,000 pixels. Got: %" PRIu64 " pixels", width); + } + m_BitDepth = Enum::BitDepth::BD_8; m_ColorMode = colorMode; m_Width = width; @@ -564,6 +573,15 @@ struct LayeredFile } LayeredFile(Enum::ColorMode colorMode, uint64_t width, uint64_t height) requires std::same_as { + if (width < 1 || width > 300000) + { + PSAPI_LOG_ERROR("LayeredFile", "Invalid width for Photoshop file provided, must be in the range of 1-300,000 pixels. Got: %" PRIu64 " pixels", width); + } + if (height < 1 || height > 300000) + { + PSAPI_LOG_ERROR("LayeredFile", "Invalid height for Photoshop file provided, must be in the range of 1-300,000 pixels. Got: %" PRIu64 " pixels", width); + } + m_BitDepth = Enum::BitDepth::BD_16; m_ColorMode = colorMode; m_Width = width; @@ -571,6 +589,15 @@ struct LayeredFile } LayeredFile(Enum::ColorMode colorMode, uint64_t width, uint64_t height) requires std::same_as { + if (width < 1 || width > 300000) + { + PSAPI_LOG_ERROR("LayeredFile", "Invalid width for Photoshop file provided, must be in the range of 1-300,000 pixels. Got: %" PRIu64 " pixels", width); + } + if (height < 1 || height > 300000) + { + PSAPI_LOG_ERROR("LayeredFile", "Invalid height for Photoshop file provided, must be in the range of 1-300,000 pixels. Got: %" PRIu64 " pixels", width); + } + m_BitDepth = Enum::BitDepth::BD_32; m_ColorMode = colorMode; m_Width = width;