[Scummvm-cvs-logs] SF.net SVN: scummvm:[35584] scummvm/trunk/graphics
drmccoy at users.sourceforge.net
drmccoy at users.sourceforge.net
Sat Dec 27 23:47:35 CET 2008
Revision: 35584
http://scummvm.svn.sourceforge.net/scummvm/?rev=35584&view=rev
Author: drmccoy
Date: 2008-12-27 22:47:34 +0000 (Sat, 27 Dec 2008)
Log Message:
-----------
Adding support for specifying an index that will be ignored when building the PaletteLUT (for transparent values that should never be found)
Modified Paths:
--------------
scummvm/trunk/graphics/dither.cpp
scummvm/trunk/graphics/dither.h
Modified: scummvm/trunk/graphics/dither.cpp
===================================================================
--- scummvm/trunk/graphics/dither.cpp 2008-12-27 20:21:55 UTC (rev 35583)
+++ scummvm/trunk/graphics/dither.cpp 2008-12-27 22:47:34 UTC (rev 35584)
@@ -54,9 +54,13 @@
memset(_gots, 1, _dim1);
}
-void PaletteLUT::setPalette(const byte *palette, PaletteFormat format, byte depth) {
+void PaletteLUT::setPalette(const byte *palette, PaletteFormat format,
+ byte depth, int transp) {
+
assert((depth > 1) && (depth < 9));
+ _transp = transp;
+
int shift = 8 - depth;
// Checking for the table's and the palette's pixel format
@@ -113,6 +117,10 @@
// Going over every palette entry, searching for the closest
for (int c = 0; c < 256; c++, p += 3) {
+ // Ignore the transparent color
+ if (c == _transp)
+ continue;
+
uint32 di = SQR(d1 - p[0]) + SQR(j - p[1]) + SQR(k - p[2]);
if (di < d) {
d = di;
@@ -165,7 +173,7 @@
buildNext();
stream.writeUint32BE(MKID_BE('PLUT')); // Magic
- stream.writeUint32BE(0); // Version
+ stream.writeUint32BE(kVersion);
stream.writeByte(_depth1);
if (stream.write(_realPal, 768) != 768)
return false;
@@ -193,8 +201,7 @@
if (stream.readUint32BE() != MKID_BE('PLUT'))
return false;
- // Version
- if (stream.readUint32BE() != 0)
+ if (stream.readUint32BE() != kVersion)
return false;
byte depth1 = stream.readByte();
Modified: scummvm/trunk/graphics/dither.h
===================================================================
--- scummvm/trunk/graphics/dither.h 2008-12-27 20:21:55 UTC (rev 35583)
+++ scummvm/trunk/graphics/dither.h 2008-12-27 22:47:34 UTC (rev 35584)
@@ -71,8 +71,9 @@
* @param palette The palette, plain 256 * 3 color components.
* @param format The format the palette is in.
* @param depth The number of significant bits in each color component.
+ * @param transp An index that's seen as transparent and therefore ignored.
*/
- void setPalette(const byte *palette, PaletteFormat format, byte depth);
+ void setPalette(const byte *palette, PaletteFormat format, byte depth, int transp = -1);
/** Build the next slice.
*
@@ -111,6 +112,8 @@
bool load(Common::SeekableReadStream &stream);
private:
+ static const uint32 kVersion = 1;
+
byte _depth1; //!< The table's depth for one dimension.
byte _depth2; //!< The table's depth for two dimensions.
byte _shift; //!< Amount to shift to adjust for the table's depth.
@@ -119,6 +122,8 @@
uint32 _dim2; //!< The table's entry offset for two dimensions.
uint32 _dim3; //!< The table's entry offset for three dimensions.
+ int _transp; //!< The transparent palette index.
+
PaletteFormat _format; //!< The table's palette format.
byte _lutPal[768]; //!< The palette used for looking up a color.
byte _realPal[768]; //!< The original palette.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list