[1/3] gdiplus: Add some tests for ARGB conversions.
Dmitry Timoshkov
dmitry at baikal.ru
Sun Feb 24 23:29:44 CST 2013
---
dlls/gdiplus/tests/image.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index 46e250d..a075b42 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -4107,6 +4107,77 @@ static void test_gif_properties(void)
GdipDisposeImage(image);
}
+static void test_ARGB_conversion(void)
+{
+ BYTE argb[8] = { 0x11,0x22,0x33,0x80, 0xff,0xff,0xff,0 };
+ BYTE pargb[8] = { 0x09,0x11,0x1a,0x80, 0,0,0,0 };
+ BYTE rgb32_xp[8] = { 0x11,0x22,0x33,0xff, 0xff,0xff,0xff,0xff };
+ BYTE rgb24[6] = { 0x11,0x22,0x33, 0xff,0xff,0xff };
+ BYTE *bits;
+ GpBitmap *bitmap;
+ BitmapData data;
+ GpStatus status;
+ int match;
+
+ status = GdipCreateBitmapFromScan0(2, 1, 8, PixelFormat32bppARGB, argb, &bitmap);
+ expect(Ok, status);
+
+ status = GdipBitmapLockBits(bitmap, NULL, ImageLockModeRead, PixelFormat32bppPARGB, &data);
+ expect(Ok, status);
+ ok(data.Width == 2, "expected 2, got %d\n", data.Width);
+ ok(data.Height == 1, "expected 1, got %d\n", data.Height);
+ ok(data.Stride == 8, "expected 8, got %d\n", data.Stride);
+ ok(data.PixelFormat == PixelFormat32bppPARGB, "expected PixelFormat32bppPARGB, got %d\n", data.PixelFormat);
+ match = !memcmp(data.Scan0, pargb, sizeof(pargb));
+todo_wine
+ ok(match, "bits don't match\n");
+ if (!match)
+ {
+ bits = data.Scan0;
+ trace("format %#x, bits %02x,%02x,%02x,%02x %02x,%02x,%02x,%02x\n", PixelFormat32bppPARGB,
+ bits[0], bits[1], bits[2], bits[3], bits[4], bits[5], bits[6], bits[7]);
+ }
+ status = GdipBitmapUnlockBits(bitmap, &data);
+ expect(Ok, status);
+
+ status = GdipBitmapLockBits(bitmap, NULL, ImageLockModeRead, PixelFormat32bppRGB, &data);
+ expect(Ok, status);
+ ok(data.Width == 2, "expected 2, got %d\n", data.Width);
+ ok(data.Height == 1, "expected 1, got %d\n", data.Height);
+ ok(data.Stride == 8, "expected 8, got %d\n", data.Stride);
+ ok(data.PixelFormat == PixelFormat32bppRGB, "expected PixelFormat32bppRGB, got %d\n", data.PixelFormat);
+ match = !memcmp(data.Scan0, argb, sizeof(argb)) ||
+ !memcmp(data.Scan0, rgb32_xp, sizeof(rgb32_xp));
+ ok(match, "bits don't match\n");
+ if (!match)
+ {
+ bits = data.Scan0;
+ trace("format %#x, bits %02x,%02x,%02x,%02x %02x,%02x,%02x,%02x\n", PixelFormat32bppRGB,
+ bits[0], bits[1], bits[2], bits[3], bits[4], bits[5], bits[6], bits[7]);
+ }
+ status = GdipBitmapUnlockBits(bitmap, &data);
+ expect(Ok, status);
+
+ status = GdipBitmapLockBits(bitmap, NULL, ImageLockModeRead, PixelFormat24bppRGB, &data);
+ expect(Ok, status);
+ ok(data.Width == 2, "expected 2, got %d\n", data.Width);
+ ok(data.Height == 1, "expected 1, got %d\n", data.Height);
+ ok(data.Stride == 8, "expected 8, got %d\n", data.Stride);
+ ok(data.PixelFormat == PixelFormat24bppRGB, "expected PixelFormat24bppRGB, got %d\n", data.PixelFormat);
+ match = !memcmp(data.Scan0, rgb24, sizeof(rgb24));
+ ok(match, "bits don't match\n");
+ if (!match)
+ {
+ bits = data.Scan0;
+ trace("format %#x, bits %02x,%02x,%02x,%02x %02x,%02x,%02x,%02x\n", PixelFormat24bppRGB,
+ bits[0], bits[1], bits[2], bits[3], bits[4], bits[5], bits[6], bits[7]);
+ }
+ status = GdipBitmapUnlockBits(bitmap, &data);
+ expect(Ok, status);
+
+ GdipDisposeImage((GpImage *)bitmap);
+}
+
START_TEST(image)
{
struct GdiplusStartupInput gdiplusStartupInput;
@@ -4119,6 +4190,7 @@ START_TEST(image)
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
+ test_ARGB_conversion();
test_DrawImage_scale();
test_image_format();
test_DrawImage();
--
1.8.1.3
More information about the wine-patches
mailing list