Commit 293c6d24 authored by Jeff Smith's avatar Jeff Smith Committed by Alexandre Julliard

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.
parent 77189a34
......@@ -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);
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment