aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2016-08-25 02:59:23 +0200
committerWillem Jan Palenstijn2016-08-25 02:59:52 +0200
commit866f0a62572c47b223efbf344602eea77797fd1b (patch)
tree0a962bc78db3ee3047203d2c2759289f6a5dd33b
parent6890948f748d6b3c63314d8756b03bc4ec8660f8 (diff)
downloadscummvm-rg350-866f0a62572c47b223efbf344602eea77797fd1b.tar.gz
scummvm-rg350-866f0a62572c47b223efbf344602eea77797fd1b.tar.bz2
scummvm-rg350-866f0a62572c47b223efbf344602eea77797fd1b.zip
DIRECTOR: Clean up padding in image decoding
-rw-r--r--engines/director/frame.cpp19
-rw-r--r--engines/director/images.cpp13
2 files changed, 17 insertions, 15 deletions
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index 078f4eba60..451a406746 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -571,18 +571,13 @@ Image::ImageDecoder *Frame::getImageFrom(uint16 spriteId) {
if (!c)
debugC(4, kDebugImages, "%d, %d, %d", imgId, w, h);
- if (true || bc->flags & 0x20) {
- int w1 = w + 16 - w % 16;
-
- if (pic->size() * 8 == w1 * h) {
- debugC(3, kDebugImages, "Disabling compression for %d: %d x %d", imgId, w1, h);
- img = new BITDDecoder(w1, h, false);
- } else if (w % 16 <= 8) {
- // FIXME: This shouldn't actually increase the width of the surface, probably, but only affect the decoder
- img = new BITDDecoder(w + 8, h, true);
- } else {
- img = new BITDDecoder(w, h, true);
- }
+ int w1 = w;
+ if (w % 16)
+ w1 += 16 - w % 16;
+
+ if (pic->size() * 8 == w1 * h) {
+ debugC(3, kDebugImages, "Disabling compression for %d: %d x %d", imgId, w1, h);
+ img = new BITDDecoder(w, h, false);
} else {
img = new BITDDecoder(w, h, true);
}
diff --git a/engines/director/images.cpp b/engines/director/images.cpp
index cd4487dd74..af35224067 100644
--- a/engines/director/images.cpp
+++ b/engines/director/images.cpp
@@ -106,7 +106,14 @@ bool DIBDecoder::loadStream(Common::SeekableReadStream &stream) {
BITDDecoder::BITDDecoder(int w, int h, bool comp) {
_surface = new Graphics::Surface();
- _surface->create(w, h, Graphics::PixelFormat::createFormatCLUT8());
+
+ int pitch = w;
+ if (w % 16)
+ pitch += 16 - (w % 16);
+
+ // HACK: Create a padded surface by adjusting w after create()
+ _surface->create(pitch, h, Graphics::PixelFormat::createFormatCLUT8());
+ _surface->w = w;
_palette = new byte[256 * 3];
@@ -140,7 +147,7 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
if (!_comp) {
debugC(3, kDebugImages, "Skipping compression");
for (y = 0; y < _surface->h; y++) {
- for (x = 0; x < _surface->w;) {
+ for (x = 0; x < _surface->pitch; ) {
byte color = stream.readByte();
for (int c = 0; c < 8; c++)
*((byte *)_surface->getBasePtr(x++, y)) = (color & (1 << (7 - c))) ? 0 : 0xff;
@@ -180,7 +187,7 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
for (int c = 0; c < 8; c++) {
*((byte *)_surface->getBasePtr(x, y)) = (color & (1 << (7 - c))) ? 0 : 0xff;
x++;
- if (x == _surface->w) {
+ if (x == _surface->pitch) {
y++;
x = 0;
break;