diff options
author | Alexandre Bouvier <contact@amb.tf> | 2023-10-12 16:36:26 +0200 |
---|---|---|
committer | Alexandre Bouvier <contact@amb.tf> | 2023-10-25 21:47:32 +0200 |
commit | 79ba5d9c260ca4e2890b8e9c9efd79e3df5fe763 (patch) | |
tree | 31f33d5ccac863e5584b3be53cd2e07a314c9b8e /src/core/hle/service/caps/caps_manager.cpp | |
parent | Merge pull request #11812 from german77/save_capture (diff) | |
download | yuzu-79ba5d9c260ca4e2890b8e9c9efd79e3df5fe763.tar yuzu-79ba5d9c260ca4e2890b8e9c9efd79e3df5fe763.tar.gz yuzu-79ba5d9c260ca4e2890b8e9c9efd79e3df5fe763.tar.bz2 yuzu-79ba5d9c260ca4e2890b8e9c9efd79e3df5fe763.tar.lz yuzu-79ba5d9c260ca4e2890b8e9c9efd79e3df5fe763.tar.xz yuzu-79ba5d9c260ca4e2890b8e9c9efd79e3df5fe763.tar.zst yuzu-79ba5d9c260ca4e2890b8e9c9efd79e3df5fe763.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/caps/caps_manager.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/core/hle/service/caps/caps_manager.cpp b/src/core/hle/service/caps/caps_manager.cpp index 9c9454b99..7d733eb54 100644 --- a/src/core/hle/service/caps/caps_manager.cpp +++ b/src/core/hle/service/caps/caps_manager.cpp @@ -2,13 +2,11 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include <sstream> -#include <stb_image.h> -#include <stb_image_resize.h> -#include <stb_image_write.h> #include "common/fs/file.h" #include "common/fs/path_util.h" #include "common/logging/log.h" +#include "common/stb.h" #include "core/core.h" #include "core/hle/service/caps/caps_manager.h" #include "core/hle/service/caps/caps_result.h" @@ -409,6 +407,12 @@ Result AlbumManager::LoadImage(std::span<u8> out_image, const std::filesystem::p return ResultSuccess; } +static void PNGToMemory(void* context, void* png, int len) { + std::vector<u8>* png_image = static_cast<std::vector<u8>*>(context); + png_image->reserve(len); + std::memcpy(png_image->data(), png, len); +} + Result AlbumManager::SaveImage(ApplicationAlbumEntry& out_entry, std::span<const u8> image, u64 title_id, const AlbumFileDateTime& date) const { const auto screenshot_path = @@ -422,16 +426,12 @@ Result AlbumManager::SaveImage(ApplicationAlbumEntry& out_entry, std::span<const const Common::FS::IOFile db_file{file_path, Common::FS::FileAccessMode::Write, Common::FS::FileType::BinaryFile}; - s32 len; - const u8* png = stbi_write_png_to_mem(image.data(), 0, 1280, 720, STBI_rgb_alpha, &len); - - if (!png) { + std::vector<u8> png_image; + if (!stbi_write_png_to_func(PNGToMemory, &png_image, 1280, 720, STBI_rgb_alpha, image.data(), + 0)) { return ResultFileCountLimit; } - std::vector<u8> png_image(len); - std::memcpy(png_image.data(), png, len); - if (db_file.Write(png_image) != png_image.size()) { return ResultFileCountLimit; } |