summaryrefslogtreecommitdiff
path: root/src/screenshot.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-10-30 23:43:44 +0000
committersmatz <smatz@openttd.org>2009-10-30 23:43:44 +0000
commit86c40a17a95610fda7631bc203ee54c3f3ab8b93 (patch)
treed9cf44920bc36bfc9e094e136a62b49f7bc9ce43 /src/screenshot.cpp
parentee2d790b344fd9b37cf943d6d883120e77a3e444 (diff)
downloadopenttd-86c40a17a95610fda7631bc203ee54c3f3ab8b93.tar.xz
(svn r17909) -Fix: 32bpp BMP screenshots were in wrong colours on big endian machines
Diffstat (limited to 'src/screenshot.cpp')
-rw-r--r--src/screenshot.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/screenshot.cpp b/src/screenshot.cpp
index ea73c1f58..0fa309d11 100644
--- a/src/screenshot.cpp
+++ b/src/screenshot.cpp
@@ -143,6 +143,15 @@ static bool MakeBmpImage(char *name, ScreenshotCallback *callb, void *userdata,
/* render the pixels */
callb(userdata, buff, h, padw, n);
+#if TTD_ENDIAN == TTD_BIG_ENDIAN
+ if (pixelformat == 32) {
+ /* Data stored in BMP are always little endian,
+ * but we have big endian data in buffer */
+ uint32 *buff32 = (uint32 *)buff;
+ for (i = 0; i < padw * n; i++) buff32[i] = BSWAP32(buff32[i]);
+ }
+#endif
+
/* write each line */
while (n)
if (fwrite(buff + (--n) * padw * bpp, padw * bpp, 1, f) != 1) {