diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2019-01-27 21:32:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-27 21:32:26 +0100 |
commit | d0f289b0d91297c5a1094cc4f6fa98186fbfb804 (patch) | |
tree | 116fa991c278e6012bb23feb0ef9df997cd74ec1 /modules | |
parent | 45a400d90e4013dc4772616e294def4ab88c71f2 (diff) | |
parent | 3e4dab538656c0fb71ac0e2535a1e51c2b9ebe06 (diff) |
Merge pull request #25314 from marxin/fix-24417-class-memaccess
Fix class memaccess
Diffstat (limited to 'modules')
-rw-r--r-- | modules/pvr/texture_loader_pvr.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp index d3f2f3c272..01e011e64c 100644 --- a/modules/pvr/texture_loader_pvr.cpp +++ b/modules/pvr/texture_loader_pvr.cpp @@ -33,6 +33,7 @@ #include "RgbaBitmap.h" #include "core/os/file_access.h" #include <string.h> +#include <new> static void _pvrtc_decompress(Image *p_img); @@ -215,12 +216,10 @@ static void _compress_pvrtc4(Image *p_img) { int ofs, size, w, h; img->get_mipmap_offset_size_and_dimensions(i, ofs, size, w, h); Javelin::RgbaBitmap bm(w, h); - copymem(bm.GetData(), &r[ofs], size); - { + for (unsigned j = 0; j < size / 4; j++) { Javelin::ColorRgba<unsigned char> *dp = bm.GetData(); - for (int j = 0; j < size / 4; j++) { - SWAP(dp[j].r, dp[j].b); - } + /* red and Green colors are swapped. */ + new (dp) Javelin::ColorRgba<unsigned char>(r[ofs + 4 * j + 2], r[ofs + 4 * j + 1], r[ofs + 4 * j], r[ofs + 4 * j + 3]); } new_img->get_mipmap_offset_size_and_dimensions(i, ofs, size, w, h); |