From 0ad2f3da454feca1fc9ba9c3f8592e104028b936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Wed, 16 Dec 2020 15:34:50 +0100 Subject: Core: Remove ImageWrite and get rid of -Wmissing-declarations warnings --- Source/Core/Common/Image.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Source/Core/Common/Image.cpp') diff --git a/Source/Core/Common/Image.cpp b/Source/Core/Common/Image.cpp index 678a64db8c..3fe2f99109 100644 --- a/Source/Core/Common/Image.cpp +++ b/Source/Core/Common/Image.cpp @@ -65,4 +65,29 @@ bool SavePNG(const std::string& path, const u8* input, ImageByteFormat format, u return true; } + +bool ConvertRGBAToRGBAndSavePNG(const std::string& path, const u8* input, u32 width, u32 height, + int stride) +{ + const std::vector data = RGBAToRGB(input, width, height, stride); + return SavePNG(path, data.data(), ImageByteFormat::RGB, width, height); +} + +std::vector RGBAToRGB(const u8* input, u32 width, u32 height, int row_stride) +{ + std::vector buffer; + buffer.reserve(width * height * 3); + + for (u32 y = 0; y < height; ++y) + { + const u8* pos = input + y * row_stride; + for (u32 x = 0; x < width; ++x) + { + buffer.push_back(pos[x * 4]); + buffer.push_back(pos[x * 4 + 1]); + buffer.push_back(pos[x * 4 + 2]); + } + } + return buffer; +} } // namespace Common -- cgit v1.2.3