Added some traces for image handling

This commit is contained in:
emeric
2024-03-30 00:04:57 +01:00
parent a91fc78d80
commit 9ca4ac073a
3 changed files with 12 additions and 2 deletions
+3
View File
@@ -20,12 +20,15 @@
#include "SvgImage.hpp"
#include <fstream>
#include "core/ITraceLogger.hpp"
#include "image/Exception.hpp"
namespace lms::image
{
std::unique_ptr<IEncodedImage> readSvgFile(const std::filesystem::path& p)
{
LMS_SCOPED_TRACE_DETAILED("Image", "ReadSVG");
if (p.extension() != ".svg")
throw Exception{ "Unexpected file extension: '" + p.extension().string() + "', expected .svg" };
+3
View File
@@ -22,6 +22,7 @@
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <stb_image_write.h>
#include "core/ITraceLogger.hpp"
#include "image/Exception.hpp"
#include "RawImage.hpp"
@@ -29,6 +30,8 @@ namespace lms::image::STB
{
JPEGImage::JPEGImage(const RawImage& rawImage, unsigned quality)
{
LMS_SCOPED_TRACE_DETAILED("Image", "WriteJPEG");
auto writeCb {[](void* ctx, void* writeData, int writeSize)
{
auto& output {*reinterpret_cast<std::vector<std::byte>*>(ctx)};
+6 -2
View File
@@ -30,19 +30,21 @@
#include <stb_image.h>
#include <stb_image_resize.h>
#include "JPEGImage.hpp"
#include "core/ITraceLogger.hpp"
#include "image/Exception.hpp"
#include "JPEGImage.hpp"
namespace lms::image
{
std::unique_ptr<IRawImage> decodeImage(const std::byte* encodedData, std::size_t encodedDataSize)
{
LMS_SCOPED_TRACE_DETAILED("Image", "DecodeBuffer");
return std::make_unique<STB::RawImage>(encodedData, encodedDataSize);
}
std::unique_ptr<IRawImage> decodeImage(const std::filesystem::path& path)
{
LMS_SCOPED_TRACE_DETAILED("Image", "DecodeFile");
return std::make_unique<STB::RawImage>(path);
}
@@ -71,6 +73,8 @@ namespace lms::image::STB
void RawImage::resize(ImageSize width)
{
LMS_SCOPED_TRACE_DETAILED("Image", "Resize");
size_t height;
if (_width == _height)
{