Jeff Smith : d3drm: Fix components of palette when loading texture from 8-bit BMP file.

Alexandre Julliard julliard at winehq.org
Mon Jul 25 16:20:46 CDT 2022


Module: wine
Branch: master
Commit: 3c914dc2ae22295e17d319564225c2727d3c602e
URL:    https://gitlab.winehq.org/wine/wine/-/commit/3c914dc2ae22295e17d319564225c2727d3c602e

Author: Jeff Smith <whydoubt at gmail.com>
Date:   Fri Jul 22 07:39:28 2022 -0500

d3drm: Fix components of palette when loading texture from 8-bit BMP file.

---

 dlls/d3drm/tests/d3drm.c | 9 +++++----
 dlls/d3drm/texture.c     | 4 +++-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c
index 3153f7191f4..2166c8eaf2a 100644
--- a/dlls/d3drm/tests/d3drm.c
+++ b/dlls/d3drm/tests/d3drm.c
@@ -6189,9 +6189,9 @@ static char *create_bitmap(unsigned int w, unsigned int h, BOOL palettized)
     {
         for (i = 0; i < 256; ++i)
         {
-            info->bmiColors[i].rgbBlue = i;
-            info->bmiColors[i].rgbGreen = i;
-            info->bmiColors[i].rgbRed = i;
+            info->bmiColors[i].rgbBlue = i % MOD_B;
+            info->bmiColors[i].rgbGreen = i % MOD_G;
+            info->bmiColors[i].rgbRed = i % MOD_R;
         }
     }
     ret = WriteFile(file, info, size, &written, NULL);
@@ -6317,7 +6317,8 @@ static void test_bitmap_data(unsigned int test_idx, const D3DRMIMAGE *img,
     ok(img->palette_size == 256, "Test %u: Got unexpected palette size %u.\n", test_idx, img->palette_size);
     for (i = 0; i < 256; ++i)
     {
-        ok(img->palette[i].red == i && img->palette[i].green == i && img->palette[i].blue == i,
+        ok(img->palette[i].red == i % MOD_R
+                && img->palette[i].green == i % MOD_G && img->palette[i].blue == i % MOD_B,
                 "Test %u: Got unexpected palette entry (%u) color 0x%02x%02x%02x.\n",
                 test_idx, i, img->palette[i].red, img->palette[i].green, img->palette[i].blue);
         ok(img->palette[i].flags == D3DRMPALETTE_READONLY,
diff --git a/dlls/d3drm/texture.c b/dlls/d3drm/texture.c
index 29e304d8598..08cc69410cb 100644
--- a/dlls/d3drm/texture.c
+++ b/dlls/d3drm/texture.c
@@ -219,9 +219,11 @@ static HRESULT d3drm_image_load_8(D3DRMIMAGE *image, const RGBQUAD *palette,
         return D3DRMERR_BADALLOC;
     }
 
-    memcpy(image->palette, palette, 256 * sizeof(*image->palette));
     for (i = 0; i < 256; ++i)
     {
+        image->palette[i].red = palette[i].rgbRed;
+        image->palette[i].green = palette[i].rgbGreen;
+        image->palette[i].blue = palette[i].rgbBlue;
         image->palette[i].flags = D3DRMPALETTE_READONLY;
     }
 




More information about the wine-cvs mailing list