From: Vijay Kiran Kamuju infyquest@gmail.com
--- dlls/gdiplus/gdiplus_private.h | 13 ++++ dlls/gdiplus/image.c | 109 +++++++++++++++++++++++++++++++-- dlls/gdiplus/tests/image.c | 103 +++++++++++++++++++++++++++---- include/gdipluseffects.h | 1 + 4 files changed, 208 insertions(+), 18 deletions(-)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 44d3e6d1000..6325ab40aa0 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -386,6 +386,19 @@ typedef enum EffectType { typedef struct CGpEffect{ INT datasize; void *data; + union params { + struct BlurParams *blurparams; + struct SharpenParams *sharpenparams; + struct TintParams *tintparams; + struct RedEyeCorrectionParams *redeyeparams; + ColorMatrix *clrmatrixparams; + struct ColorLUTParams *clrlutparams; + struct BrightnessContrastParams *brtcntrstparams; + struct HueSaturationLightnessParams *huesatliteparams; + struct ColorBalanceParams *clrbalanceparams; + struct LevelsParams *levelsparams; + struct ColorCurveParams *clrcurveparams; + } p; EffectType type; } CGpEffect;
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index f8b98de460d..3aed62b1015 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -5591,46 +5591,57 @@ GpStatus WINGDIPAPI GdipCreateEffect(const GUID guid, CGpEffect **effect) if (IsEqualGUID(&guid, &BlurEffectGuid)) { ef->type = BlurEffect; + ef->p.blurparams = NULL; } else if (IsEqualGUID(&guid, &SharpenEffectGuid)) { ef->type = SharpenEffect; + ef->p.sharpenparams = NULL; } else if (IsEqualGUID(&guid, &TintEffectGuid)) { ef->type = TintEffect; + ef->p.tintparams = NULL; } else if (IsEqualGUID(&guid, &RedEyeCorrectionEffectGuid)) { ef->type = RedEyeCorrectionEffect; + ef->p.redeyeparams = NULL; } else if (IsEqualGUID(&guid, &ColorMatrixEffectGuid)) { ef->type = ColorMatrixEffect; + ef->p.clrmatrixparams = NULL; } else if (IsEqualGUID(&guid, &ColorLUTEffectGuid)) { ef->type = ColorLUTEffect; + ef->p.clrlutparams = NULL; } else if (IsEqualGUID(&guid, &BrightnessContrastEffectGuid)) { ef->type = BrightnessContrastEffect; + ef->p.brtcntrstparams = NULL; } else if (IsEqualGUID(&guid, &HueSaturationLightnessEffectGuid)) { ef->type = HueSaturationLightnessEffect; + ef->p.huesatliteparams = NULL; } else if (IsEqualGUID(&guid, &ColorBalanceEffectGuid)) { ef->type = ColorBalanceEffect; + ef->p.clrbalanceparams = NULL; } else if (IsEqualGUID(&guid, &LevelsEffectGuid)) { ef->type = LevelsEffect; + ef->p.levelsparams = NULL; } else if (IsEqualGUID(&guid, &ColorCurveEffectGuid)) { ef->type = ColorCurveEffect; + ef->p.clrcurveparams = NULL; } else { @@ -5679,6 +5690,8 @@ GpStatus WINGDIPAPI GdipGetEffectParameterSize(CGpEffect *effect, UINT *size) break; case RedEyeCorrectionEffect: sz = sizeof(struct RedEyeCorrectionParams); + if (effect->p.redeyeparams) + sz += effect->p.redeyeparams->numberOfAreas*sizeof(RECT); break; case ColorMatrixEffect: sz = sizeof(ColorMatrix); @@ -5705,8 +5718,8 @@ GpStatus WINGDIPAPI GdipGetEffectParameterSize(CGpEffect *effect, UINT *size) status = InvalidParameter; break; } - *size = sz; + return status; }
@@ -5716,14 +5729,100 @@ 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; + switch (effect->type) + { + case BlurEffect: + paramsize = sizeof(struct BlurParams); + if (paramsize != size) + return InvalidParameter; + effect->p.blurparams = malloc(size); + memcpy(effect->p.blurparams, params, size); + break; + case SharpenEffect: + paramsize = sizeof(struct SharpenParams); + if (paramsize != size) + return InvalidParameter; + effect->p.sharpenparams = malloc(size); + memcpy(effect->p.sharpenparams, params, size); + break; + case TintEffect: + paramsize = sizeof(struct TintParams); + if (paramsize != size) + return InvalidParameter; + effect->p.tintparams = malloc(size); + memcpy(effect->p.tintparams, params, size); + break; + case RedEyeCorrectionEffect: + paramsize = sizeof(struct RedEyeCorrectionParams); + if ((paramsize-size > 0) || (((size-paramsize)%sizeof(RECT)) != 0)) + return InvalidParameter; + effect->p.redeyeparams = malloc(paramsize); + num = (size-paramsize)/sizeof(RECT); + effect->p.redeyeparams->numberOfAreas = num; + effect->p.redeyeparams->areas = malloc(num*sizeof(RECT)); + memcpy(effect->p.redeyeparams->areas, ((struct RedEyeCorrectionParams *)params)->areas, num*sizeof(RECT)); + break; + case ColorMatrixEffect: + paramsize = sizeof(ColorMatrix); + if (paramsize != size) + return InvalidParameter; + effect->p.clrmatrixparams = malloc(size); + memcpy(effect->p.clrmatrixparams, params, size); + break; + case ColorLUTEffect: + paramsize = sizeof(struct ColorLUTParams); + if (paramsize != size) + return InvalidParameter; + effect->p.clrlutparams = malloc(size); + memcpy(effect->p.clrlutparams, params, size); + break; + case BrightnessContrastEffect: + paramsize = sizeof(struct BrightnessContrastParams); + if (paramsize != size) + return InvalidParameter; + effect->p.brtcntrstparams = malloc(size); + memcpy(effect->p.brtcntrstparams, params, size); + break; + case HueSaturationLightnessEffect: + paramsize = sizeof(struct HueSaturationLightnessParams); + if (paramsize != size) + return InvalidParameter; + effect->p.huesatliteparams = malloc(size); + memcpy(effect->p.huesatliteparams, params, size); + break; + case ColorBalanceEffect: + paramsize = sizeof(struct ColorBalanceParams); + if (paramsize != size) + return InvalidParameter; + effect->p.clrbalanceparams = malloc(size); + memcpy(effect->p.clrbalanceparams, params, size); + break; + case LevelsEffect: + paramsize = sizeof(struct LevelsParams); + if (paramsize != size) + return InvalidParameter; + effect->p.levelsparams = malloc(size); + memcpy(effect->p.levelsparams, params, size); + break; + case ColorCurveEffect: + paramsize = sizeof(struct ColorCurveParams); + if (paramsize != size) + return InvalidParameter; + effect->p.clrcurveparams = malloc(size); + memcpy(effect->p.clrcurveparams, params, size); + break; + default: + return InvalidParameter; + } + + return Ok; }
/***************************************************************************** diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index 3cd7f8f3d19..fab6261f444 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -5408,37 +5408,96 @@ 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; UINT size; + void *params = NULL; 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, 3.0, 3.0, 3.0, 3.0 }, + { 4.0, 4.0, 4.0, 4.0, 4.0 }, + { 5.0, 5.0, 5.0, 5.0, 5.0 } + } + }; + struct ColorLUTParams lut = + { + { 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3, + 4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7, + 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3, + 4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7, + 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3, + 4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7, + 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3, + 4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7 }, + { 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3, + 4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7, + 8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11, + 12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15, + 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3, + 4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7, + 8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11, + 12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15 }, + { 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3, + 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3, + 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3, + 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3, + 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3, + 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3, + 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3, + 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3 }, + { 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,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,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,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,9 +5511,15 @@ static void test_createeffect(void) stat = pGdipGetEffectParameterSize(NULL, NULL); expect(InvalidParameter, stat);
+ stat = pGdipSetEffectParameters(NULL, NULL, 0); + expect(InvalidParameter, stat); + stat = pGdipGetEffectParameterSize(effect, NULL); expect(InvalidParameter, stat);
+ stat = pGdipSetEffectParameters(effect, params, 0); + expect(InvalidParameter, stat); + stat = pGdipCreateEffect(noneffect, &effect); expect(Win32Error, stat);
@@ -5462,6 +5527,12 @@ static void test_createeffect(void) stat = pGdipGetEffectParameterSize(effect, &size); expect(InvalidParameter, stat); expect(0, size); + stat = pGdipSetEffectParameters(effect, (void *)0xdeadbeef, 0); + expect(InvalidParameter, stat); + stat = pGdipSetEffectParameters(effect, (void *)0xdeadbeef, 8); + expect(InvalidParameter, stat); + stat = pGdipSetEffectParameters(effect, (void *)0xdeadbeef, 5); + expect(InvalidParameter, stat);
for(i=0; i < ARRAY_SIZE(td); i++) { @@ -5475,6 +5546,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 }