Vincent Povirk : gdiplus: Implement GdipSetImageAttributesGamma.
Alexandre Julliard
julliard at winehq.org
Mon Feb 1 08:55:57 CST 2010
Module: wine
Branch: master
Commit: 762845ca8c1df295f3819a51849f4f271b406afb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=762845ca8c1df295f3819a51849f4f271b406afb
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Sat Jan 30 17:09:06 2010 -0600
gdiplus: Implement GdipSetImageAttributesGamma.
---
dlls/gdiplus/gdiplus_private.h | 2 +
dlls/gdiplus/imageattributes.c | 11 ++++---
dlls/gdiplus/tests/image.c | 63 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+), 5 deletions(-)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index 9d05e0d..d82eec1 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -263,6 +263,8 @@ struct GpImageAttributes{
WrapMode wrap;
struct color_key colorkeys[ColorAdjustTypeCount];
struct color_matrix colormatrices[ColorAdjustTypeCount];
+ BOOL gamma_enabled[ColorAdjustTypeCount];
+ REAL gamma[ColorAdjustTypeCount];
};
struct GpFont{
diff --git a/dlls/gdiplus/imageattributes.c b/dlls/gdiplus/imageattributes.c
index 56e5ab2..c9c3bcc 100644
--- a/dlls/gdiplus/imageattributes.c
+++ b/dlls/gdiplus/imageattributes.c
@@ -149,14 +149,15 @@ GpStatus WINGDIPAPI GdipSetImageAttributesCachedBackground(GpImageAttributes *im
GpStatus WINGDIPAPI GdipSetImageAttributesGamma(GpImageAttributes *imageAttr,
ColorAdjustType type, BOOL enableFlag, REAL gamma)
{
- static int calls;
-
TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, gamma);
- if(!(calls++))
- FIXME("not implemented\n");
+ if (!imageAttr || (enableFlag && gamma <= 0.0) || type >= ColorAdjustTypeCount)
+ return InvalidParameter;
- return NotImplemented;
+ imageAttr->gamma_enabled[type] = enableFlag;
+ imageAttr->gamma[type] = gamma;
+
+ return Ok;
}
GpStatus WINGDIPAPI GdipSetImageAttributesNoOp(GpImageAttributes *imageAttr,
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index e93b745..fe49425 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -1365,6 +1365,68 @@ static void test_colormatrix(void)
GdipDisposeImageAttributes(imageattr);
}
+static void test_gamma(void)
+{
+ GpStatus stat;
+ GpImageAttributes *imageattr;
+ GpBitmap *bitmap1, *bitmap2;
+ GpGraphics *graphics;
+ ARGB color;
+
+ stat = GdipSetImageAttributesGamma(NULL, ColorAdjustTypeDefault, TRUE, 1.0);
+ expect(InvalidParameter, stat);
+
+ stat = GdipCreateImageAttributes(&imageattr);
+ expect(Ok, stat);
+
+ stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, TRUE, 1.0);
+ expect(Ok, stat);
+
+ stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeAny, TRUE, 1.0);
+ expect(InvalidParameter, stat);
+
+ stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, TRUE, -1.0);
+ expect(InvalidParameter, stat);
+
+ stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, TRUE, 0.0);
+ expect(InvalidParameter, stat);
+
+ stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, TRUE, 0.5);
+ expect(Ok, stat);
+
+ stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, FALSE, 0.0);
+ expect(Ok, stat);
+
+ /* Drawing a bitmap transforms the colors */
+ stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, TRUE, 3.0);
+ expect(Ok, stat);
+
+ stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB, NULL, &bitmap1);
+ expect(Ok, stat);
+
+ stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB, NULL, &bitmap2);
+ expect(Ok, stat);
+
+ stat = GdipBitmapSetPixel(bitmap1, 0, 0, 0xff80ffff);
+ expect(Ok, stat);
+
+ stat = GdipGetImageGraphicsContext((GpImage*)bitmap2, &graphics);
+ expect(Ok, stat);
+
+ stat = GdipDrawImageRectRectI(graphics, (GpImage*)bitmap1, 0,0,1,1, 0,0,1,1,
+ UnitPixel, imageattr, NULL, NULL);
+ expect(Ok, stat);
+
+ stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
+ expect(Ok, stat);
+ todo_wine expect(0xff20ffff, color);
+
+ GdipDeleteGraphics(graphics);
+ GdipDisposeImage((GpImage*)bitmap1);
+ GdipDisposeImage((GpImage*)bitmap2);
+ GdipDisposeImageAttributes(imageattr);
+}
+
/* 1x1 pixel gif, 2 frames; first frame is white, second is black */
static const unsigned char gifanimation[72] = {
0x47,0x49,0x46,0x38,0x39,0x61,0x01,0x00,0x01,0x00,0xa1,0x00,0x00,0x00,0x00,0x00,
@@ -1533,6 +1595,7 @@ START_TEST(image)
test_getsetpixel();
test_palette();
test_colormatrix();
+ test_gamma();
test_multiframegif();
GdiplusShutdown(gdiplusToken);
More information about the wine-cvs
mailing list