Blur effect _under_ a component

Hi, I'd like to apply a blur effect under a component, i.e. everything under the component rectangle is blurred but the component itself is not blurred. So, in the paint(Graphics&) method, I draw the parentComponent() and all of its children (excepted //this//) in an Image before blurring the Image and painting it as a background. But this needs two consecutive paint(Graphics&) calls on every Component in the hierarchy, or more if I want to add multiple of such overlay components. Any idea of a tweak or another strategy in order to achieve that in a light manner? If only Graphics permitted access to the Image Region… :)

Hey fbecker, would createComponentSnapshot or paintEntireComponent help?

1 Like

Hey fabian, yeah that's actually what I replicated, the code looks about like:

        Graphics lG(mBackground);
        
        lG.saveState();
        getParentComponent()->paint(lG);
        lG.restoreState();
        for (int i = 0 ; i != getParentComponent()->getNumChildComponents() ; ++i)
        {
            Component* child = getParentComponent()->getChildComponent(i);
            if (child != this && child->isVisible())
            {
                lG.saveState();
                lG.setOrigin (child->getPosition());
                child->paintEntireComponent (lG, true);
                lG.restoreState();
            }
        }
        
        g.drawImageWithin(mBackground, 100, 100, 300, 300, RectanglePlacement::stretchToFit);

but my question is rather: could I avoid redrawing all these components and get (Graphics&) g's current image contents?