Jeff Smith : d3drm: Fix components of palette built when loading texture from file.
Alexandre Julliard
julliard at winehq.org
Thu Jul 21 17:02:57 CDT 2022
Module: wine
Branch: master
Commit: 293c6d24e39a3c99455c15f243bafb3d87043088
URL: https://gitlab.winehq.org/wine/wine/-/commit/293c6d24e39a3c99455c15f243bafb3d87043088
Author: Jeff Smith <whydoubt at gmail.com>
Date: Tue Jul 19 08:51:11 2022 -0500
d3drm: Fix components of palette built when loading texture from file.
Fix the palette-building code used by IDirect3DTexture::InitFromFile
to use color components correctly. Also, fix and expand the tests to
properly check the components of a built palette.
---
dlls/d3drm/tests/d3drm.c | 5 +++--
dlls/d3drm/texture.c | 8 ++++----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c
index 87986547a4d..3153f7191f4 100644
--- a/dlls/d3drm/tests/d3drm.c
+++ b/dlls/d3drm/tests/d3drm.c
@@ -6287,8 +6287,8 @@ static void test_bitmap_data(unsigned int test_idx, const D3DRMIMAGE *img,
for (i = 0; i < img->palette_size; ++i)
{
unsigned int idx = upside_down ? (h - 1) * w - i + (i % w) * 2 : i;
- ok(img->palette[i].red == idx % MOD_B
- && img->palette[i].green == idx % MOD_G && img->palette[i].blue == idx % MOD_R,
+ ok(img->palette[i].red == idx % MOD_R
+ && img->palette[i].green == idx % MOD_G && img->palette[i].blue == idx % 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,
@@ -6367,6 +6367,7 @@ static void test_load_texture(void)
{100, 100, FALSE},
{99, 100, FALSE},
{3, 39, FALSE},
+ {16, 16, FALSE},
};
hr = Direct3DRMCreate(&d3drm1);
diff --git a/dlls/d3drm/texture.c b/dlls/d3drm/texture.c
index a60317b48bc..29e304d8598 100644
--- a/dlls/d3drm/texture.c
+++ b/dlls/d3drm/texture.c
@@ -103,9 +103,9 @@ static BOOL d3drm_image_palettise(D3DRMIMAGE *image, unsigned char *src_data,
for (i = 0; i < colour_count; ++i)
{
entry = &palette[i];
- if (entry->red == src_ptr[x * 3 + 0]
+ if (entry->red == src_ptr[x * 3 + 2]
&& entry->green == src_ptr[x * 3 + 1]
- && entry->blue == src_ptr[x * 3 + 2])
+ && entry->blue == src_ptr[x * 3 + 0])
break;
}
@@ -119,9 +119,9 @@ static BOOL d3drm_image_palettise(D3DRMIMAGE *image, unsigned char *src_data,
}
entry = &palette[colour_count++];
- entry->red = src_ptr[x * 3 + 0];
+ entry->red = src_ptr[x * 3 + 2];
entry->green = src_ptr[x * 3 + 1];
- entry->blue = src_ptr[x * 3 + 2];
+ entry->blue = src_ptr[x * 3 + 0];
entry->flags = D3DRMPALETTE_READONLY;
}
More information about the wine-cvs
mailing list