diff options
author | md5 | 2011-04-27 13:44:19 +0300 |
---|---|---|
committer | md5 | 2011-04-27 13:44:19 +0300 |
commit | 27e4a1dee524fb4979a3ba2430b6c82d486be853 (patch) | |
tree | 09263add9ab41046a34194cae0cbe6e709832cf5 | |
parent | 99e30284593a58fb95edf35a74b5ba2374b485e3 (diff) | |
download | scummvm-rg350-27e4a1dee524fb4979a3ba2430b6c82d486be853.tar.gz scummvm-rg350-27e4a1dee524fb4979a3ba2430b6c82d486be853.tar.bz2 scummvm-rg350-27e4a1dee524fb4979a3ba2430b6c82d486be853.zip |
PNG: Changed getPalette() to properly return a copy of the image palette
-rw-r--r-- | graphics/png.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/graphics/png.h b/graphics/png.h index 00c084da8e..af6630c9c4 100644 --- a/graphics/png.h +++ b/graphics/png.h @@ -117,18 +117,18 @@ public: } /** - * Returns the palette of the specified PNG8 image. - * - * Note that the palette's format is RGBA. + * Returns the palette of the specified PNG8 image, given a pointer to + * an RGBA palette array (4 x 256). */ - void getPalette(byte *&palette, uint16 &entries) { + void getPalette(byte *palette, uint16 &entries) { if (_header.colorType != kIndexed) error("Palette requested for a non-indexed PNG"); - // TODO: It might be that this should really return a copy of the - // palette, but since the implementation was like this I changed - // the palette pointer to be a reference instead of a value copy. - // Someone should check this code and verify this is as intended. - palette = _palette; + for (int i = 0; i < 256; i++) { + palette[0 + i * 4] = _palette[0 + i * 4]; // R + palette[1 + i * 4] = _palette[1 + i * 4]; // G + palette[2 + i * 4] = _palette[2 + i * 4]; // B + palette[3 + i * 4] = _palette[3 + i * 4]; // A + } entries = _paletteEntries; } |