summaryrefslogtreecommitdiff
path: root/lib/Image.cc
diff options
context:
space:
mode:
authorPixel <Pixel>2002-01-08 22:24:26 +0000
committerPixel <Pixel>2002-01-08 22:24:26 +0000
commit151bbc76aefe11bfbcabcbab5266784d46e6e6ae (patch)
tree92da9b25afcea2648b5a0e4e41aceca2c6b3c16c /lib/Image.cc
parent63d1339b8576c7962ab5d185fbad3fc5b36a6875 (diff)
TGA & Endianness
Diffstat (limited to 'lib/Image.cc')
-rw-r--r--lib/Image.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Image.cc b/lib/Image.cc
index 9b41b4e..0848e8b 100644
--- a/lib/Image.cc
+++ b/lib/Image.cc
@@ -39,6 +39,10 @@ void Image::SetPixel(unsigned int px, unsigned int py, Color c) {
img[x * py + px] = c;
}
+#ifndef WORDS_BIGENDIAN
+#define WORDS_BIGENDIAN 0
+#endif
+
bool Image::Prepare(unsigned int f) {
if (GetSize()) return false;
@@ -55,8 +59,8 @@ bool Image::Prepare(unsigned int f) {
Header.CM_EntrySize = 0;
Header.IS_XOrigin = 0;
Header.IS_YOrigin = 0;
- Header.IS_Width = x;
- Header.IS_Height = y;
+ Header.IS_Width = WORDS_BIGENDIAN ? ((x & 0xff) << 8) || ((x & 0xff00) >> 8) : x;
+ Header.IS_Height = WORDS_BIGENDIAN ? ((y & 0xff) << 8) || ((y & 0xff00) >> 8) : y;
Header.IS_Depth = 32;
Header.IS_Descriptor = 0x20;