[Scummvm-git-logs] scummvm master -> c6dbbe48b79c4177e6853e1fb2b2ea6f383f2a4d

sev- noreply at scummvm.org
Sat Nov 11 22:01:20 UTC 2023


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
dae8cf474c GRAPHICS: Add a function for creating maps to PaletteLookup
c6dbbe48b7 Update graphics/palette.cpp


Commit: dae8cf474ca026e5317c819c7c64057f3a9b06b3
    https://github.com/scummvm/scummvm/commit/dae8cf474ca026e5317c819c7c64057f3a9b06b3
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-11-11T23:01:16+01:00

Commit Message:
GRAPHICS: Add a function for creating maps to PaletteLookup

Changed paths:
    graphics/palette.cpp
    graphics/palette.h


diff --git a/graphics/palette.cpp b/graphics/palette.cpp
index 8c0c388723e..9bce4d2cb3b 100644
--- a/graphics/palette.cpp
+++ b/graphics/palette.cpp
@@ -94,4 +94,19 @@ byte PaletteLookup::findBestColor(byte cr, byte cg, byte cb, bool useNaiveAlg) {
 	return bestColor;
 }
 
+uint32 *PaletteLookup::createMap(const byte *srcPalette, uint len, bool useNaiveAlg) {
+	if (len <= _paletteSize && memcmp(_palette, srcPalette, len) == 0)
+		return nullptr;
+
+	uint32 *map = new uint32[len];
+	for (uint i = 0; i < len; i++) {
+		byte r = *srcPalette++;
+		byte g = *srcPalette++;
+		byte b = *srcPalette++;
+
+		map[i] = findBestColor(r, g, b, useNaiveAlg);
+	}
+	return map;
+}
+
 } // end of namespace Graphics
diff --git a/graphics/palette.h b/graphics/palette.h
index 93f9d41a366..8ebad3fdb1b 100644
--- a/graphics/palette.h
+++ b/graphics/palette.h
@@ -143,6 +143,18 @@ public:
 	 */
 	byte findBestColor(byte r, byte g, byte b, bool useNaiveAlg = false);
 
+	/**
+	 * @brief This method creates a map from the given palette
+	 *        that can be used by crossBlitMap().
+	 *
+	 * @param palette   the palette data, in interleaved RGB format
+	 * @param len       the number of palette entries to be read
+	 * @param useNaiveAlg            if true, use a simpler algorithm (non-floating point calculations)
+	 *
+	 * @return the created map, or nullptr if one isn't needed.
+	 */
+	uint32 *createMap(const byte *srcPalette, uint len, bool useNaiveAlg = false);
+
 private:
 	byte _palette[256 * 3];
 	uint _paletteSize;


Commit: c6dbbe48b79c4177e6853e1fb2b2ea6f383f2a4d
    https://github.com/scummvm/scummvm/commit/c6dbbe48b79c4177e6853e1fb2b2ea6f383f2a4d
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-11-11T23:01:16+01:00

Commit Message:
Update graphics/palette.cpp

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

Changed paths:
    graphics/palette.cpp


diff --git a/graphics/palette.cpp b/graphics/palette.cpp
index 9bce4d2cb3b..1568af8c343 100644
--- a/graphics/palette.cpp
+++ b/graphics/palette.cpp
@@ -95,7 +95,7 @@ byte PaletteLookup::findBestColor(byte cr, byte cg, byte cb, bool useNaiveAlg) {
 }
 
 uint32 *PaletteLookup::createMap(const byte *srcPalette, uint len, bool useNaiveAlg) {
-	if (len <= _paletteSize && memcmp(_palette, srcPalette, len) == 0)
+	if (len <= _paletteSize && memcmp(_palette, srcPalette, len * 3) == 0)
 		return nullptr;
 
 	uint32 *map = new uint32[len];




More information about the Scummvm-git-logs mailing list