From 33a88e5cacb35e04c947abe38565423544605fcf Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 25 Apr 2011 15:45:05 +0200 Subject: PNG: This PNG::getPalette. Formerly the palette parameter was a value copy, which was assigned in getPalette. That did not make much sense, thus I changed it to be a reference. Since I am not quite sure whether this really shouldn't make a palette copy I added an TODO comment about it. --- graphics/png.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'graphics/png.h') diff --git a/graphics/png.h b/graphics/png.h index 70f2e4ba27..00c084da8e 100644 --- a/graphics/png.h +++ b/graphics/png.h @@ -121,9 +121,13 @@ public: * * Note that the palette's format is RGBA. */ - 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; entries = _paletteEntries; } -- cgit v1.2.3 From 27e4a1dee524fb4979a3ba2430b6c82d486be853 Mon Sep 17 00:00:00 2001 From: md5 Date: Wed, 27 Apr 2011 13:44:19 +0300 Subject: PNG: Changed getPalette() to properly return a copy of the image palette --- graphics/png.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'graphics/png.h') 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; } -- cgit v1.2.3 From 9414d7a6e287ff8abfb5746b564e92c8f0e6de58 Mon Sep 17 00:00:00 2001 From: Ori Avtalion Date: Sun, 24 Apr 2011 11:34:27 +0300 Subject: JANITORIAL: Reduce header dependencies in shared code Some backends may break as I only compiled SDL --- graphics/png.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'graphics/png.h') diff --git a/graphics/png.h b/graphics/png.h index af6630c9c4..21e0f35be1 100644 --- a/graphics/png.h +++ b/graphics/png.h @@ -31,8 +31,6 @@ #ifndef GRAPHICS_PNG_H #define GRAPHICS_PNG_H -#include "graphics/surface.h" - // PNG decoder, based on the W3C specs: // http://www.w3.org/TR/PNG/ // Parts of the code have been adapted from LodePNG, by Lode Vandevenne: @@ -54,12 +52,17 @@ // is a bit unclear. For now, these won't be supported, until a suitable sample // is found. +#include "common/scummsys.h" +#include "common/textconsole.h" + namespace Common { class SeekableReadStream; } namespace Graphics { +struct Surface; + enum PNGColorType { kGrayScale = 0, // bit depths: 1, 2, 4, 8, 16 kTrueColor = 2, // bit depths: 8, 16 -- cgit v1.2.3