From: Vijay Kiran Kamuju infyquest@gmail.com
--- dlls/gdiplus/gdiplus_private.h | 1 + dlls/gdiplus/image.c | 39 ++++++++++++-- dlls/gdiplus/tests/image.c | 92 ++++++++++++++++++++++++++++------ include/gdipluseffects.h | 1 + 4 files changed, 114 insertions(+), 19 deletions(-)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 778a2ef5298..16ecdf010b9 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -384,6 +384,7 @@ typedef enum EffectType { } EffectType;
typedef struct CGpEffect{ + void *params; EffectType type; } CGpEffect;
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index f3cf246bf77..5f11f61bd0c 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -5635,6 +5635,7 @@ GpStatus WINGDIPAPI GdipCreateEffect(const GUID guid, CGpEffect **effect) }
ef = malloc(sizeof(CGpEffect)); + ef->params = NULL; ef->type = type; *effect = ef;
@@ -5648,6 +5649,7 @@ GpStatus WINGDIPAPI GdipDeleteEffect(CGpEffect *effect) { TRACE("(%p)\n", effect);
+ free(effect->params); free(effect); return Ok; } @@ -5678,6 +5680,8 @@ GpStatus WINGDIPAPI GdipGetEffectParameterSize(CGpEffect *effect, UINT *size) break; case RedEyeCorrectionEffect: sz = sizeof(struct RedEyeCorrectionParams); + if (effect->params) + sz += (((struct RedEyeCorrectionParams *)effect->params)->numberOfAreas)*sizeof(RECT); break; case ColorMatrixEffect: sz = sizeof(ColorMatrix); @@ -5704,8 +5708,8 @@ GpStatus WINGDIPAPI GdipGetEffectParameterSize(CGpEffect *effect, UINT *size) status = InvalidParameter; break; } - *size = sz; + return status; }
@@ -5715,14 +5719,39 @@ GpStatus WINGDIPAPI GdipGetEffectParameterSize(CGpEffect *effect, UINT *size) GpStatus WINGDIPAPI GdipSetEffectParameters(CGpEffect *effect, const VOID *params, const UINT size) { - static int calls; + UINT paramsize = 0, num = 0;
TRACE("(%p,%p,%u)\n", effect, params, size);
- if(!(calls++)) - FIXME("not implemented\n"); + if (!effect || !params || !size) + return InvalidParameter;
- return NotImplemented; + if (GdipGetEffectParameterSize(effect, ¶msize) != Ok) + return InvalidParameter; + + if (effect->type == RedEyeCorrectionEffect) + { + if ((paramsize-size > 0) || (((size-paramsize)%sizeof(RECT)) != 0)) + return InvalidParameter; + } + else + { + if (paramsize != size) + return InvalidParameter; + } + + effect->params = realloc(effect->params, size); + if (effect->type == RedEyeCorrectionEffect) + { + num = (size-paramsize)/sizeof(RECT); + ((struct RedEyeCorrectionParams *)effect->params)->numberOfAreas = num; + ((struct RedEyeCorrectionParams *)effect->params)->areas = malloc(num*sizeof(RECT)); + memcpy(((struct RedEyeCorrectionParams *)params)->areas, ((struct RedEyeCorrectionParams *)effect->params)->areas, num*sizeof(RECT)); + } + else + memcpy(effect->params, params, size); + + return Ok; }
/***************************************************************************** diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index 471f9909c80..747cefd9fad 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -5408,37 +5408,95 @@ static void test_createeffect(void) GpStatus (WINAPI *pGdipCreateEffect)( const GUID guid, CGpEffect **effect); GpStatus (WINAPI *pGdipDeleteEffect)( CGpEffect *effect); GpStatus (WINAPI *pGdipGetEffectParameterSize)( CGpEffect *effect, UINT *size); + GpStatus (WINAPI *pGdipSetEffectParameters)( CGpEffect *effect, const VOID *params, const UINT size); GpStatus stat; CGpEffect *effect = NULL; UINT size; HMODULE mod = GetModuleHandleA("gdiplus.dll"); int i;
- static const struct test_data { + RECT rects[2] = { { 0, 0, 75, 75 }, { -32, -32, 32, 32 } }; + struct BlurParams blur = { 2.0, TRUE }; + struct SharpenParams sharpen = { 5.0, 2 }; + ColorMatrix matrix = + { + { + { 1.0, 1.0, 1.0, 1.0, 1.0 }, + { 2.0, 2.0, 2.0, 2.0, 2.0 }, + { 3.0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } + }; + struct BrightnessContrastParams bc = { 75, 50 }; + struct HueSaturationLightnessParams hsl = { 50, 50, 50 }; + struct LevelsParams lvl = { 50, 50, 5 }; + struct TintParams tint = { 20, 5 }; + struct ColorBalanceParams cbal = { 50, 50, 50 }; + struct ColorCurveParams ccurve = { AdjustExposure, CurveChannelAll, 5 }; + struct RedEyeCorrectionParams redi = { 2, rects }; + const struct test_data { const GUID *guid; UINT size; + void *params; } td[] = { - { &BlurEffectGuid, 8 }, - { &SharpenEffectGuid, 8 }, - { &ColorMatrixEffectGuid, 100 }, - { &ColorLUTEffectGuid, 1024 }, - { &BrightnessContrastEffectGuid, 8 }, - { &HueSaturationLightnessEffectGuid, 12 }, - { &LevelsEffectGuid, 12 }, - { &TintEffectGuid, 8 }, - { &ColorBalanceEffectGuid, 12 }, + { &BlurEffectGuid, 8, &blur }, + { &SharpenEffectGuid, 8, &sharpen }, + { &ColorMatrixEffectGuid, 100, &matrix }, + { &ColorLUTEffectGuid, 1024, &lut }, + { &BrightnessContrastEffectGuid, 8, &bc }, + { &HueSaturationLightnessEffectGuid, 12, &hsl }, + { &LevelsEffectGuid, 12, &lvl }, + { &TintEffectGuid, 8, &tint }, + { &ColorBalanceEffectGuid, 12, &cbal }, #ifdef _WIN64 - { &RedEyeCorrectionEffectGuid, 16 }, + { &RedEyeCorrectionEffectGuid, 16, &redi }, #else - { &RedEyeCorrectionEffectGuid, 8 }, + { &RedEyeCorrectionEffectGuid, 8, &redi }, #endif - { &ColorCurveEffectGuid, 12 } + { &ColorCurveEffectGuid, 12, &ccurve } };
pGdipCreateEffect = (void*)GetProcAddress( mod, "GdipCreateEffect"); pGdipDeleteEffect = (void*)GetProcAddress( mod, "GdipDeleteEffect"); pGdipGetEffectParameterSize = (void*)GetProcAddress( mod, "GdipGetEffectParameterSize"); + pGdipSetEffectParameters = (void*)GetProcAddress( mod, "GdipSetEffectParameters"); if(!pGdipCreateEffect || !pGdipDeleteEffect) { /* GdipCreateEffect/GdipDeleteEffect was introduced in Windows Vista. */ @@ -5452,7 +5510,7 @@ static void test_createeffect(void) stat = pGdipGetEffectParameterSize(NULL, NULL); expect(InvalidParameter, stat);
- stat = pGdipGetEffectParameterSize(effect, NULL); + stat = pGdipSetEffectParameters(NULL, NULL, 0); expect(InvalidParameter, stat);
effect = (CGpEffect *)0xdeadbeef; @@ -5472,6 +5530,12 @@ static void test_createeffect(void) expect(Ok, stat); expect(td[i].size, size);
+ stat = pGdipSetEffectParameters(effect, td[i].params, td[i].size); + expect(Ok, stat); + size = 0; + stat = pGdipGetEffectParameterSize(effect, &size); + expect(td[i].size, size); + stat = pGdipDeleteEffect(effect); expect(Ok, stat); } diff --git a/include/gdipluseffects.h b/include/gdipluseffects.h index a58d25cb0e3..2b94479f7f5 100644 --- a/include/gdipluseffects.h +++ b/include/gdipluseffects.h @@ -112,6 +112,7 @@ extern "C" { GpStatus WINGDIPAPI GdipCreateEffect(const GUID guid, CGpEffect **effect); GpStatus WINGDIPAPI GdipDeleteEffect(CGpEffect *effect); GpStatus WINGDIPAPI GdipGetEffectParameterSize(CGpEffect *effect, UINT *size); +GpStatus WINGDIPAPI GdipSetEffectParameters(CGpEffect *effect, const VOID *params, const UINT size);
#ifdef __cplusplus }