Add Image RGBA Flip func
This commit is contained in:
@@ -12,5 +12,6 @@ CTRFF_API void RGBA2RGB565(ctrff::u16 *out, const std::vector<ctrff::u8> &img,
|
|||||||
const int &w, const int &h);
|
const int &w, const int &h);
|
||||||
CTRFF_API std::vector<ctrff::u8> DownscaleImage(
|
CTRFF_API std::vector<ctrff::u8> DownscaleImage(
|
||||||
const std::vector<ctrff::u8> &img, int w, int h, int scale);
|
const std::vector<ctrff::u8> &img, int w, int h, int scale);
|
||||||
|
CTRFF_API void Flip(std::vector<u8> &buf, int w, int h);
|
||||||
CTRFF_API ctrff::u32 TileIndex(const int &x, const int &y, const int &w);
|
CTRFF_API ctrff::u32 TileIndex(const int &x, const int &y, const int &w);
|
||||||
} // namespace ctrff
|
} // namespace ctrff
|
||||||
@@ -58,6 +58,7 @@ SOFTWARE.
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <numeric>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|||||||
@@ -87,6 +87,20 @@ CTRFF_API std::vector<ctrff::u8> ctrff::DownscaleImage(
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CTRFF_API void ctrff::Flip(std::vector<ctrff::u8> &buf, int w, int h) {
|
||||||
|
std::vector<ctrff::u8> 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,
|
CTRFF_API void ctrff::String2U16(ctrff::u16 *res, const std::string &src,
|
||||||
size_t max) {
|
size_t max) {
|
||||||
/// GOT FORCED TO REPLACE std::wstring_convert by some
|
/// GOT FORCED TO REPLACE std::wstring_convert by some
|
||||||
|
|||||||
Reference in New Issue
Block a user