aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2017-01-01 02:36:01 -0500
committerPaul Gilbert2017-01-01 02:36:01 -0500
commitbc039f6b10dc8203f007c943815473d20b5c672b (patch)
tree2571679700de508835e7951031d1535bdc6a8e71
parent00fd499b5715ff4f1dde84ff8d9e76f996d9a4e8 (diff)
downloadscummvm-rg350-bc039f6b10dc8203f007c943815473d20b5c672b.tar.gz
scummvm-rg350-bc039f6b10dc8203f007c943815473d20b5c672b.tar.bz2
scummvm-rg350-bc039f6b10dc8203f007c943815473d20b5c672b.zip
IMAGE: Properly load bottom origin RLE encoded TGA images
-rw-r--r--image/tga.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/image/tga.cpp b/image/tga.cpp
index adfe7eefbb..b23c597ed5 100644
--- a/image/tga.cpp
+++ b/image/tga.cpp
@@ -27,6 +27,7 @@
#include "image/tga.h"
#include "common/util.h"
+#include "common/algorithm.h"
#include "common/stream.h"
#include "common/textconsole.h"
#include "common/error.h"
@@ -437,6 +438,22 @@ bool TGADecoder::readDataRLE(Common::SeekableReadStream &tga, byte imageType, by
} else {
return false;
}
+
+ // If it's a bottom origin image, we need to vertically flip the image
+ if (!_originTop) {
+ byte *tempLine = new byte[_surface.pitch];
+ byte *line1 = (byte *)_surface.getBasePtr(0, 0);
+ byte *line2 = (byte *)_surface.getBasePtr(0, _surface.h - 1);
+
+ for (int y = 0; y < (_surface.h / 2); ++y, line1 += _surface.pitch, line2 -= _surface.pitch) {
+ Common::copy(line1, line1 + _surface.pitch, tempLine);
+ Common::copy(line2, line2 + _surface.pitch, line1);
+ Common::copy(tempLine, tempLine + _surface.pitch, line2);
+ }
+
+ delete[] tempLine;
+ }
+
return true;
}