From 8823b2cc7262441fbb263c5f004432f6f637a0f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 9 Jan 2012 19:08:25 +0100 Subject: [PATCH] TGAImporter: think about endianness! --- src/Plugins/TGAImporter/TGAImporter.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Plugins/TGAImporter/TGAImporter.cpp b/src/Plugins/TGAImporter/TGAImporter.cpp index f02d7c803..f2547164e 100644 --- a/src/Plugins/TGAImporter/TGAImporter.cpp +++ b/src/Plugins/TGAImporter/TGAImporter.cpp @@ -15,6 +15,7 @@ #include "TGAImporter.h" +#include "Utility/Endianness.h" #include "Math/Vector2.h" #include "Image.h" @@ -32,8 +33,11 @@ bool TGAImporter::open(std::istream& in) { Header header; in.read(reinterpret_cast(&header), sizeof(Header)); - ColorFormat colorFormat; + /* Convert to machine endian */ + header.width = Endianness::littleEndian(header.width); + header.height = Endianness::littleEndian(header.height); + ColorFormat colorFormat; switch(header.bpp) { case 24: colorFormat = ColorFormat::BGR;