diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2025-05-03 17:36:22 -0500 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2025-05-03 18:32:30 -0500 |
| commit | 5a80105555b3602cf4547654a3c9ac4d5af0c427 (patch) | |
| tree | 9e48c262d6cc0834b65dc1be7599f5693852ec1d /Source/Core/InputCommon/ImageOperations.cpp | |
| parent | a736d2ed5f570f818d71968cc17511e27972af6f (diff) | |
Common and VideoCommon: Change texture data from std::vector to Common::UniqueBuffer.
Diffstat (limited to 'Source/Core/InputCommon/ImageOperations.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ImageOperations.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/Source/Core/InputCommon/ImageOperations.cpp b/Source/Core/InputCommon/ImageOperations.cpp index 04293c9183..907cb52b8d 100644 --- a/Source/Core/InputCommon/ImageOperations.cpp +++ b/Source/Core/InputCommon/ImageOperations.cpp @@ -5,12 +5,9 @@ #include <algorithm> #include <cmath> -#include <limits> -#include <stack> #include <string> #include <vector> -#include "Common/FileUtil.h" #include "Common/IOFile.h" #include "Common/Image.h" @@ -49,11 +46,11 @@ std::optional<ImagePixelData> LoadImage(const std::string& path) { File::IOFile file; file.Open(path, "rb"); - std::vector<u8> buffer(file.GetSize()); + Common::UniqueBuffer<u8> buffer(file.GetSize()); file.ReadBytes(buffer.data(), file.GetSize()); ImagePixelData image; - std::vector<u8> data; + Common::UniqueBuffer<u8> data; if (!Common::LoadPNG(buffer, &data, &image.width, &image.height)) return std::nullopt; @@ -74,19 +71,20 @@ std::optional<ImagePixelData> LoadImage(const std::string& path) bool WriteImage(const std::string& path, const ImagePixelData& image) { - std::vector<u8> buffer; - buffer.reserve(image.width * image.height * 4); + Common::UniqueBuffer<u8> buffer; + buffer.reset(image.width * image.height * 4); + std::size_t buffer_index = 0; for (u32 y = 0; y < image.height; ++y) { for (u32 x = 0; x < image.width; ++x) { const auto index = x + y * image.width; const auto pixel = image.pixels[index]; - buffer.push_back(pixel.r); - buffer.push_back(pixel.g); - buffer.push_back(pixel.b); - buffer.push_back(pixel.a); + buffer[buffer_index++] = pixel.r; + buffer[buffer_index++] = pixel.g; + buffer[buffer_index++] = pixel.b; + buffer[buffer_index++] = pixel.a; } } |
