Direct2D: applying effect to entire window and specific areas in the client area

thebluetropics 1,046 Reputation points
2022-10-04T04:22:07.66+00:00

An example from https://learn.microsoft.com/en-us/windows/win32/direct2d/gaussian-blur:

   ComPtr<ID2D1Effect> gaussianBlurEffect;  
   m_d2dContext->CreateEffect(CLSID_D2D1GaussianBlur, &gaussianBlurEffect);  
     
   gaussianBlurEffect->SetInput(0, bitmap);  
   gaussianBlurEffect->SetValue(D2D1_GAUSSIANBLUR_PROP_STANDARD_DEVIATION, 3.0f);  
     
   m_d2dContext->BeginDraw();  
   m_d2dContext->DrawImage(gaussianBlurEffect.Get());  
   m_d2dContext->EndDraw();  

In the example above, I have understand how effect works in Direct2D. However, the example above is only limited to applying the effect into a bitmap (ID2D1Bitmap?).

What I want to achieve with Direct2D effect is:

  1. Applying the effect to specific areas
  2. Applying the effect to entire client area
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,450 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,564 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 82,121 Reputation points
    2022-10-04T06:46:46.873+00:00

    Use ID2D1Effect::SetInputEffect to combine multiple effects

    A quick test with CLSID_D2D1Crop, CLSID_D2D1Scale and CLSID_D2D1GaussianBlur (bad quality GIF for Gaussian, but it is for the idea...) :

    247226-direct2d-gaussianblur.gif


1 additional answer

Sort by: Most helpful
  1. Jeanine Zhang-MSFT 9,266 Reputation points Microsoft Vendor
    2022-10-04T06:14:04.373+00:00

    Hi, @thebluetropics

    According to the Doc: Effects

    You can use Direct2D to apply one or more high quality effects to an image or a set of images.

    ID2D1Effect::SetInput method: Sets the given input image by index.

    As far as I'm concerned, Direct2D Effects is limited to applying the effect to image.