From ef8dcea383e4c68608e46e4e7614de0c3b87da1c Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Thu, 24 Mar 2011 17:31:57 -0500 Subject: [PATCH] gdiplus: Implement gamma adjustment. --- dlls/gdiplus/graphics.c | 28 +++++++++++++++++++++++++--- dlls/gdiplus/tests/image.c | 2 +- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 7d2dbcd..334dd2c 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -408,9 +408,31 @@ static void apply_image_attributes(const GpImageAttributes *attributes, LPBYTE d if (attributes->gamma_enabled[type] || attributes->gamma_enabled[ColorAdjustTypeDefault]) { - static int fixme; - if (!fixme++) - FIXME("Gamma adjustment not implemented\n"); + REAL gamma; + + if (attributes->gamma_enabled[type]) + gamma = attributes->gamma[type]; + else + gamma = attributes->gamma[ColorAdjustTypeDefault]; + + for (x=0; x>8)&0xff; + red = (*src_color>>16)&0xff; + + /* FIXME: We should probably use a table for this. */ + blue = floorf(powf(blue / 255.0, gamma) * 255.0); + green = floorf(powf(green / 255.0, gamma) * 255.0); + red = floorf(powf(red / 255.0, gamma) * 255.0); + + *src_color = (*src_color & 0xff000000) | (red << 16) | (green << 8) | blue; + } } } diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index 71a99ea..9e1a9c2 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -2063,7 +2063,7 @@ static void test_gamma(void) stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color); expect(Ok, stat); - todo_wine ok(color_match(0xff20ffff, color, 1), "Expected ff20ffff, got %.8x\n", color); + ok(color_match(0xff20ffff, color, 1), "Expected ff20ffff, got %.8x\n", color); GdipDeleteGraphics(graphics); GdipDisposeImage((GpImage*)bitmap1); -- 1.7.1