summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorMax Hilbrunner <mhilbrunner@users.noreply.github.com>2019-04-25 13:39:07 +0200
committerGitHub <noreply@github.com>2019-04-25 13:39:07 +0200
commit80ad49748e5b4cf9f7f7672500e0212db4265f20 (patch)
tree47c075dd51c34ccfce2875b4ed08bd5ee489336e /modules
parent8c948800cdc535fe109e806a7171015f11fa012c (diff)
parentd0f0f1f1cb1ef5478b3ac3b00597c8b17974ffc4 (diff)
Merge pull request #28265 from Xrayez/fix-tga-indexed-palette
Fix TGA indexed images loaded with flipped color table
Diffstat (limited to 'modules')
-rw-r--r--modules/tga/image_loader_tga.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/modules/tga/image_loader_tga.cpp b/modules/tga/image_loader_tga.cpp
index 419229677b..a3c0f5ded7 100644
--- a/modules/tga/image_loader_tga.cpp
+++ b/modules/tga/image_loader_tga.cpp
@@ -148,9 +148,11 @@ Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buff
uint8_t a = 0xff;
if (p_header.color_map_depth == 24) {
- r = (p_palette[(index * 3) + 0]);
+ // Due to low-high byte order, the color table must be
+ // read in the same order as image data (little endian)
+ r = (p_palette[(index * 3) + 2]);
g = (p_palette[(index * 3) + 1]);
- b = (p_palette[(index * 3) + 2]);
+ b = (p_palette[(index * 3) + 0]);
} else {
return ERR_INVALID_DATA;
}