Implement few effect related functions in Gdiplus.
-- v33: gdiplus: Partial implementation of GdipGetEffectParameterSize. gdiplus: Add GdipCreateEffect implementation.
From: Vijay Kiran Kamuju infyquest@gmail.com
--- dlls/gdiplus/gdiplus_private.h | 19 ++++++++++ dlls/gdiplus/image.c | 69 ++++++++++++++++++++++++++++++---- dlls/gdiplus/tests/image.c | 9 +++-- 3 files changed, 86 insertions(+), 11 deletions(-)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index d247b973b3b..a81220b130c 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -379,6 +379,25 @@ struct GpAdjustableArrowCap{ REAL width; };
+typedef enum EffectType { + NoneEffect, + BlurEffect, + SharpenEffect, + TintEffect, + RedEyeCorrectionEffect, + ColorMatrixEffect, + ColorLUTEffect, + BrightnessContrastEffect, + HueSaturationLightnessEffect, + ColorBalanceEffect, + LevelsEffect, + ColorCurveEffect, +} EffectType; + +typedef struct CGpEffect{ + EffectType type; +} CGpEffect; + struct GpImage{ IWICBitmapDecoder *decoder; IWICBitmapEncoder *encoder; diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 9362cdc344d..8e35b4ab7c8 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -5509,14 +5509,69 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi */ GpStatus WINGDIPAPI GdipCreateEffect(const GUID guid, CGpEffect **effect) { - FIXME("(%s, %p): stub\n", debugstr_guid(&guid), effect); + CGpEffect *ef = NULL; + EffectType type; + + TRACE("(%s, %p)\n", debugstr_guid(&guid), effect);
if(!effect) return InvalidParameter;
- *effect = NULL; + if (IsEqualGUID(&guid, &BlurEffectGuid)) + { + type = BlurEffect; + } + else if (IsEqualGUID(&guid, &SharpenEffectGuid)) + { + type = SharpenEffect; + } + else if (IsEqualGUID(&guid, &TintEffectGuid)) + { + type = TintEffect; + } + else if (IsEqualGUID(&guid, &RedEyeCorrectionEffectGuid)) + { + type = RedEyeCorrectionEffect; + } + else if (IsEqualGUID(&guid, &ColorMatrixEffectGuid)) + { + type = ColorMatrixEffect; + } + else if (IsEqualGUID(&guid, &ColorLUTEffectGuid)) + { + type = ColorLUTEffect; + } + else if (IsEqualGUID(&guid, &BrightnessContrastEffectGuid)) + { + type = BrightnessContrastEffect; + } + else if (IsEqualGUID(&guid, &HueSaturationLightnessEffectGuid)) + { + type = HueSaturationLightnessEffect; + } + else if (IsEqualGUID(&guid, &ColorBalanceEffectGuid)) + { + type = ColorBalanceEffect; + } + else if (IsEqualGUID(&guid, &LevelsEffectGuid)) + { + type = LevelsEffect; + } + else if (IsEqualGUID(&guid, &ColorCurveEffectGuid)) + { + type = ColorCurveEffect; + } + else + { + *effect = NULL; + return Win32Error; + }
- return NotImplemented; + ef = malloc(sizeof(CGpEffect)); + ef->type = type; + *effect = ef; + + return Ok; }
/***************************************************************************** @@ -5524,13 +5579,13 @@ GpStatus WINGDIPAPI GdipCreateEffect(const GUID guid, CGpEffect **effect) */ GpStatus WINGDIPAPI GdipDeleteEffect(CGpEffect *effect) { - FIXME("(%p): stub\n", effect); + TRACE("(%p)\n", effect);
if (!effect) return InvalidParameter; - /* note: According to Jose Roca's GDI+ Docs, this is not implemented - * in Windows's gdiplus */ - return NotImplemented; + + free(effect); + return Ok; }
/***************************************************************************** diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index d3ac65148d2..bfcd149f4fa 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -5410,7 +5410,7 @@ static void test_createeffect(void) GpStatus (WINAPI *pGdipGetEffectParameterSize)(CGpEffect *effect, UINT *size); GpStatus (WINAPI *pGdipGetEffectParameters)(CGpEffect *effect, const VOID *params, const UINT size); GpStatus stat; - CGpEffect *effect; + CGpEffect *effect = NULL; HMODULE mod = GetModuleHandleA("gdiplus.dll"); int i; UINT param_size; @@ -5449,7 +5449,8 @@ static void test_createeffect(void) expect(InvalidParameter, stat);
stat = pGdipCreateEffect(noneffect, &effect); - todo_wine expect(Win32Error, stat); + expect(Win32Error, stat); + ok( !effect, "expected null effect\n");
param_size = 0; stat = pGdipGetEffectParameterSize(NULL, ¶m_size); @@ -5459,12 +5460,12 @@ static void test_createeffect(void) for (i = 0; i < ARRAY_SIZE(td); i++) { stat = pGdipCreateEffect(*(td[i].effect), &effect); - todo_wine_if(td[i].todo) expect(Ok, stat); + expect(Ok, stat); if (stat == Ok) { param_size = 0; stat = pGdipGetEffectParameterSize(effect, ¶m_size); - todo_wine_if(td[i].todo) expect(Ok, stat); + expect(Ok, stat); #ifdef _WIN64 /* Parameter Size for Red Eye Correction effect is different for 64 bits build */ if (td[i].effect == &RedEyeCorrectionEffectGuid)
From: Vijay Kiran Kamuju infyquest@gmail.com
--- dlls/gdiplus/image.c | 49 ++++++++++++++++++++++++++++++++++++-- dlls/gdiplus/tests/image.c | 38 +++++++++++++---------------- 2 files changed, 64 insertions(+), 23 deletions(-)
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 8e35b4ab7c8..65a179ec037 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -5593,11 +5593,56 @@ GpStatus WINGDIPAPI GdipDeleteEffect(CGpEffect *effect) */ GpStatus WINGDIPAPI GdipGetEffectParameterSize(CGpEffect *effect, UINT *size) { - FIXME("(%p,%p): stub\n", effect, size); + UINT sz = 0; + GpStatus status = Ok; + + TRACE("(%p,%p)\n", effect, size);
if (!effect || !size) return InvalidParameter; - return NotImplemented; + + switch (effect->type) + { + case BlurEffect: + sz = sizeof(struct BlurParams); + break; + case SharpenEffect: + sz = sizeof(struct SharpenParams); + break; + case TintEffect: + sz = sizeof(struct TintParams); + break; + case RedEyeCorrectionEffect: + sz = sizeof(struct RedEyeCorrectionParams); + break; + case ColorMatrixEffect: + sz = sizeof(ColorMatrix); + break; + case ColorLUTEffect: + sz = sizeof(struct ColorLUTParams); + break; + case BrightnessContrastEffect: + sz = sizeof(struct BrightnessContrastParams); + break; + case HueSaturationLightnessEffect: + sz = sizeof(struct HueSaturationLightnessParams); + break; + case ColorBalanceEffect: + sz = sizeof(struct ColorBalanceParams); + break; + case LevelsEffect: + sz = sizeof(struct LevelsParams); + break; + case ColorCurveEffect: + sz = sizeof(struct ColorCurveParams); + break; + default: + status = InvalidParameter; + break; + } + + *size = sz; + return status; }
/***************************************************************************** diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index bfcd149f4fa..fafbfdab113 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -5418,20 +5418,24 @@ static void test_createeffect(void) static const struct test_data { const GUID *effect; const UINT parameters_number; - const BOOL todo; } td[] = { - { &BlurEffectGuid, 8, TRUE }, - { &BrightnessContrastEffectGuid, 8, TRUE }, - { &ColorBalanceEffectGuid, 12, TRUE }, - { &ColorCurveEffectGuid, 12, TRUE }, - { &ColorLUTEffectGuid, 1024, TRUE }, - { &ColorMatrixEffectGuid, 100, TRUE }, - { &HueSaturationLightnessEffectGuid, 12, TRUE }, - { &LevelsEffectGuid, 12, TRUE }, - { &RedEyeCorrectionEffectGuid, 8, TRUE }, - { &SharpenEffectGuid, 8, TRUE }, - { &TintEffectGuid, 8, TRUE }, + { &BlurEffectGuid, 8 }, + { &BrightnessContrastEffectGuid, 8 }, + { &ColorBalanceEffectGuid, 12 }, + { &ColorCurveEffectGuid, 12 }, + { &ColorLUTEffectGuid, 1024 }, + { &ColorMatrixEffectGuid, 100 }, + { &HueSaturationLightnessEffectGuid, 12 }, + { &LevelsEffectGuid, 12 }, + /* Parameter Size for Red Eye Correction effect is different for 64 bits build */ +#ifdef _WIN64 + { &RedEyeCorrectionEffectGuid, 16 }, +#else + { &RedEyeCorrectionEffectGuid, 8 }, +#endif + { &SharpenEffectGuid, 8 }, + { &TintEffectGuid, 8 }, };
pGdipCreateEffect = (void*)GetProcAddress( mod, "GdipCreateEffect"); @@ -5466,15 +5470,7 @@ static void test_createeffect(void) param_size = 0; stat = pGdipGetEffectParameterSize(effect, ¶m_size); expect(Ok, stat); -#ifdef _WIN64 - /* Parameter Size for Red Eye Correction effect is different for 64 bits build */ - if (td[i].effect == &RedEyeCorrectionEffectGuid) - todo_wine_if(td[i].todo) expect(16, param_size); - else - todo_wine_if(td[i].todo) expect(td[i].parameters_number, param_size); -#else - todo_wine_if(td[i].todo) expect(td[i].parameters_number, param_size); -#endif + expect(td[i].parameters_number, param_size); stat = pGdipDeleteEffect(effect); expect(Ok, stat); }