diff --git a/include/ctrff/helper.hpp b/include/ctrff/helper.hpp index 727bd56..01aa437 100644 --- a/include/ctrff/helper.hpp +++ b/include/ctrff/helper.hpp @@ -12,5 +12,6 @@ CTRFF_API void RGBA2RGB565(ctrff::u16 *out, const std::vector &img, const int &w, const int &h); CTRFF_API std::vector DownscaleImage( const std::vector &img, int w, int h, int scale); +CTRFF_API void Flip(std::vector &buf, int w, int h); CTRFF_API ctrff::u32 TileIndex(const int &x, const int &y, const int &w); } // namespace ctrff \ No newline at end of file diff --git a/include/ctrff/types.hpp b/include/ctrff/types.hpp index a2131a8..35bb6b5 100644 --- a/include/ctrff/types.hpp +++ b/include/ctrff/types.hpp @@ -58,6 +58,7 @@ SOFTWARE. #include #include #include +#include #include #include #include diff --git a/source/helper.cpp b/source/helper.cpp index 16dd905..fd7ea30 100644 --- a/source/helper.cpp +++ b/source/helper.cpp @@ -87,6 +87,20 @@ CTRFF_API std::vector ctrff::DownscaleImage( return res; } +CTRFF_API void ctrff::Flip(std::vector &buf, int w, int h) { + std::vector tmp = buf; + for (int x = 0; x < w; x++) { + for (int y = 0; y < h; y++) { + int src = (y * w + x) * 4; + int dst = ((h - 1 - y) * w + x) * 4; + buf[dst + 0] = tmp[src + 0]; + buf[dst + 1] = tmp[src + 1]; + buf[dst + 2] = tmp[src + 2]; + buf[dst + 3] = tmp[src + 3]; + } + } +} + CTRFF_API void ctrff::String2U16(ctrff::u16 *res, const std::string &src, size_t max) { /// GOT FORCED TO REPLACE std::wstring_convert by some