diff options
| author | 2023-10-12 16:36:26 +0200 | |
|---|---|---|
| committer | 2023-10-25 21:47:32 +0200 | |
| commit | 79ba5d9c260ca4e2890b8e9c9efd79e3df5fe763 (patch) | |
| tree | 31f33d5ccac863e5584b3be53cd2e07a314c9b8e /src/core/hle/service/caps | |
| parent | Merge pull request #11812 from german77/save_capture (diff) | |
| download | yuzu-79ba5d9c260ca4e2890b8e9c9efd79e3df5fe763.tar.gz yuzu-79ba5d9c260ca4e2890b8e9c9efd79e3df5fe763.tar.xz yuzu-79ba5d9c260ca4e2890b8e9c9efd79e3df5fe763.zip | |
cmake: prefer system stb headers
Diffstat (limited to 'src/core/hle/service/caps')
| -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 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <sstream> | 4 | #include <sstream> |
| 5 | #include <stb_image.h> | ||
| 6 | #include <stb_image_resize.h> | ||
| 7 | #include <stb_image_write.h> | ||
| 8 | 5 | ||
| 9 | #include "common/fs/file.h" | 6 | #include "common/fs/file.h" |
| 10 | #include "common/fs/path_util.h" | 7 | #include "common/fs/path_util.h" |
| 11 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 9 | #include "common/stb.h" | ||
| 12 | #include "core/core.h" | 10 | #include "core/core.h" |
| 13 | #include "core/hle/service/caps/caps_manager.h" | 11 | #include "core/hle/service/caps/caps_manager.h" |
| 14 | #include "core/hle/service/caps/caps_result.h" | 12 | #include "core/hle/service/caps/caps_result.h" |
| @@ -409,6 +407,12 @@ Result AlbumManager::LoadImage(std::span<u8> out_image, const std::filesystem::p | |||
| 409 | return ResultSuccess; | 407 | return ResultSuccess; |
| 410 | } | 408 | } |
| 411 | 409 | ||
| 410 | static void PNGToMemory(void* context, void* png, int len) { | ||
| 411 | std::vector<u8>* png_image = static_cast<std::vector<u8>*>(context); | ||
| 412 | png_image->reserve(len); | ||
| 413 | std::memcpy(png_image->data(), png, len); | ||
| 414 | } | ||
| 415 | |||
| 412 | Result AlbumManager::SaveImage(ApplicationAlbumEntry& out_entry, std::span<const u8> image, | 416 | Result AlbumManager::SaveImage(ApplicationAlbumEntry& out_entry, std::span<const u8> image, |
| 413 | u64 title_id, const AlbumFileDateTime& date) const { | 417 | u64 title_id, const AlbumFileDateTime& date) const { |
| 414 | const auto screenshot_path = | 418 | const auto screenshot_path = |
| @@ -422,16 +426,12 @@ Result AlbumManager::SaveImage(ApplicationAlbumEntry& out_entry, std::span<const | |||
| 422 | const Common::FS::IOFile db_file{file_path, Common::FS::FileAccessMode::Write, | 426 | const Common::FS::IOFile db_file{file_path, Common::FS::FileAccessMode::Write, |
| 423 | Common::FS::FileType::BinaryFile}; | 427 | Common::FS::FileType::BinaryFile}; |
| 424 | 428 | ||
| 425 | s32 len; | 429 | std::vector<u8> png_image; |
| 426 | const u8* png = stbi_write_png_to_mem(image.data(), 0, 1280, 720, STBI_rgb_alpha, &len); | 430 | if (!stbi_write_png_to_func(PNGToMemory, &png_image, 1280, 720, STBI_rgb_alpha, image.data(), |
| 427 | 431 | 0)) { | |
| 428 | if (!png) { | ||
| 429 | return ResultFileCountLimit; | 432 | return ResultFileCountLimit; |
| 430 | } | 433 | } |
| 431 | 434 | ||
| 432 | std::vector<u8> png_image(len); | ||
| 433 | std::memcpy(png_image.data(), png, len); | ||
| 434 | |||
| 435 | if (db_file.Write(png_image) != png_image.size()) { | 435 | if (db_file.Write(png_image) != png_image.size()) { |
| 436 | return ResultFileCountLimit; | 436 | return ResultFileCountLimit; |
| 437 | } | 437 | } |