gdiplus: Round up when converting from 32-bit ARGB to PARGB.
Applies fix from d23bfd8dfc
to
setpixel_32bppPARGB.
Signed-off-by: Jeff Smith <whydoubt@gmail.com>
Signed-off-by: Vincent Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
06bf4283fb
commit
ddd88fe2f4
|
@ -459,9 +459,9 @@ static inline void setpixel_32bppARGB(BYTE r, BYTE g, BYTE b, BYTE a,
|
|||
static inline void setpixel_32bppPARGB(BYTE r, BYTE g, BYTE b, BYTE a,
|
||||
BYTE *row, UINT x)
|
||||
{
|
||||
r = r * a / 255;
|
||||
g = g * a / 255;
|
||||
b = b * a / 255;
|
||||
r = (r * a + 127) / 255;
|
||||
g = (g * a + 127) / 255;
|
||||
b = (b * a + 127) / 255;
|
||||
*((DWORD*)(row)+x) = (a<<24)|(r<<16)|(g<<8)|b;
|
||||
}
|
||||
|
||||
|
|
|
@ -4810,6 +4810,7 @@ static void test_PARGB_conversion(void)
|
|||
{
|
||||
BYTE pargb[8] = { 0x62,0x77,0x99,0x77, 0x62,0x77,0x99,0 };
|
||||
BYTE argb[8] = { 0xd1,0xfe,0xff,0x77, 0x62,0x77,0x99,0 };
|
||||
BYTE pargb2[8] = { 0x01,0x01,0x00,0x01, 0xfe,0x7f,0x7f,0xfe };
|
||||
BYTE *bits;
|
||||
GpBitmap *bitmap;
|
||||
BitmapData data;
|
||||
|
@ -4836,6 +4837,28 @@ static void test_PARGB_conversion(void)
|
|||
status = GdipBitmapUnlockBits(bitmap, &data);
|
||||
expect(Ok, status);
|
||||
|
||||
/* Testing SetPixel 32-bit ARGB to PARGB */
|
||||
status = GdipBitmapSetPixel(bitmap, 0, 0, 0x017f80ff);
|
||||
expect(Ok, status);
|
||||
status = GdipBitmapSetPixel(bitmap, 1, 0, 0xfe7f80ff);
|
||||
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, pargb2, sizeof(pargb2));
|
||||
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);
|
||||
|
||||
GdipDisposeImage((GpImage *)bitmap);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue