Vincent Povirk : windowscodecs/tests: Add a helper function for comparing bits.
Alexandre Julliard
julliard at winehq.org
Fri Sep 16 10:16:08 CDT 2016
Module: wine
Branch: master
Commit: 82f82f69174f9725ef7663307ff2571026ebedda
URL: http://source.winehq.org/git/wine.git/?a=commit;h=82f82f69174f9725ef7663307ff2571026ebedda
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Thu Sep 15 16:10:16 2016 -0500
windowscodecs/tests: Add a helper function for comparing bits.
Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/windowscodecs/tests/converter.c | 58 ++++++++++++++++--------------------
1 file changed, 26 insertions(+), 32 deletions(-)
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c
index c1599c5..d6f581d 100644
--- a/dlls/windowscodecs/tests/converter.c
+++ b/dlls/windowscodecs/tests/converter.c
@@ -196,6 +196,29 @@ static void DeleteTestBitmap(BitmapTestSrc *This)
HeapFree(GetProcessHeap(), 0, This);
}
+static BOOL compare_bits(const struct bitmap_data *expect, UINT buffersize, const BYTE *converted_bits)
+{
+ BOOL equal;
+
+ if (IsEqualGUID(expect->format, &GUID_WICPixelFormat32bppBGR))
+ {
+ /* ignore the padding byte when comparing data */
+ UINT i;
+ const DWORD *a=(const DWORD*)expect->bits, *b=(const DWORD*)converted_bits;
+ equal=TRUE;
+ for (i=0; i<(buffersize/4); i++)
+ if ((a[i]&0xffffff) != (b[i]&0xffffff))
+ {
+ equal = FALSE;
+ break;
+ }
+ }
+ else
+ equal = (memcmp(expect->bits, converted_bits, buffersize) == 0);
+
+ return equal;
+}
+
static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSource *source, const char *name)
{
BYTE *converted_bits;
@@ -231,42 +254,13 @@ static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSour
converted_bits = HeapAlloc(GetProcessHeap(), 0, buffersize);
hr = IWICBitmapSource_CopyPixels(source, &prc, stride, buffersize, converted_bits);
ok(SUCCEEDED(hr), "CopyPixels(%s) failed, hr=%x\n", name, hr);
- if (IsEqualGUID(expect->format, &GUID_WICPixelFormat32bppBGR))
- {
- /* ignore the padding byte when comparing data */
- UINT i;
- BOOL equal=TRUE;
- const DWORD *a=(const DWORD*)expect->bits, *b=(const DWORD*)converted_bits;
- for (i=0; i<(buffersize/4); i++)
- if ((a[i]&0xffffff) != (b[i]&0xffffff))
- {
- equal = FALSE;
- break;
- }
- ok(equal, "unexpected pixel data (%s)\n", name);
- }
- else
- ok(memcmp(expect->bits, converted_bits, buffersize) == 0, "unexpected pixel data (%s)\n", name);
+ ok(compare_bits(expect, buffersize, converted_bits), "unexpected pixel data (%s)\n", name);
/* Test with NULL rectangle - should copy the whole bitmap */
+ memset(converted_bits, 0xaa, buffersize);
hr = IWICBitmapSource_CopyPixels(source, NULL, stride, buffersize, converted_bits);
ok(SUCCEEDED(hr), "CopyPixels(%s,rc=NULL) failed, hr=%x\n", name, hr);
- if (IsEqualGUID(expect->format, &GUID_WICPixelFormat32bppBGR))
- {
- /* ignore the padding byte when comparing data */
- UINT i;
- BOOL equal=TRUE;
- const DWORD *a=(const DWORD*)expect->bits, *b=(const DWORD*)converted_bits;
- for (i=0; i<(buffersize/4); i++)
- if ((a[i]&0xffffff) != (b[i]&0xffffff))
- {
- equal = FALSE;
- break;
- }
- ok(equal, "unexpected pixel data with rc=NULL (%s)\n", name);
- }
- else
- ok(memcmp(expect->bits, converted_bits, buffersize) == 0, "unexpected pixel data with rc=NULL (%s)\n", name);
+ ok(compare_bits(expect, buffersize, converted_bits), "unexpected pixel data (%s)\n", name);
HeapFree(GetProcessHeap(), 0, converted_bits);
}
More information about the wine-cvs
mailing list