aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlyssa Milburn2011-04-14 21:08:03 +0200
committerAlyssa Milburn2011-04-14 21:08:03 +0200
commitc60e773981be82ae0be2c649e9a079da4dae26a9 (patch)
tree2340e762bace4a574bc57b0e5eb15a2701e69f9f
parent6ecc460b419690ba8bef8bbc3deb5af3f6c7bbc6 (diff)
downloadscummvm-rg350-c60e773981be82ae0be2c649e9a079da4dae26a9.tar.gz
scummvm-rg350-c60e773981be82ae0be2c649e9a079da4dae26a9.tar.bz2
scummvm-rg350-c60e773981be82ae0be2c649e9a079da4dae26a9.zip
GRAPHICS: Handle 4bpp paletted PNG files.
-rw-r--r--graphics/png.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/graphics/png.cpp b/graphics/png.cpp
index 96dc083092..f3a6a287fb 100644
--- a/graphics/png.cpp
+++ b/graphics/png.cpp
@@ -170,11 +170,18 @@ Graphics::Surface *PNG::getSurface(const PixelFormat &format) {
}
} else {
byte index, r, g, b;
+ bool otherPixel = false;
// Convert the indexed surface to the target pixel format
for (uint16 i = 0; i < output->h; i++) {
for (uint16 j = 0; j < output->w; j++) {
- index = *src;
+ if (_header.bitDepth != 4)
+ index = *src;
+ else if (!otherPixel)
+ index = (*src) >> 4;
+ else
+ index = (*src) & 0xf;
+
r = _palette[index * 4 + 0];
g = _palette[index * 4 + 1];
b = _palette[index * 4 + 2];
@@ -185,8 +192,12 @@ Graphics::Surface *PNG::getSurface(const PixelFormat &format) {
else
*((uint32 *)output->getBasePtr(j, i)) = format.ARGBToColor(a, r, g, b);
- src++;
+ if (_header.bitDepth != 4 || otherPixel)
+ src++;
+ otherPixel = !otherPixel;
}
+ if (_header.bitDepth == 4)
+ src += output->w/2;
}
}