Applying a custom filter to everything behind a RECT with C++, a'la CSS backdrop-filter style

Viewed 76

I want to invert the colors of everything in a window from, say, (300, 100) to (600, 500).

I tried using BitBlt with the DSTINVERT flag set from the winuser.h library, but if anything changes, it breaks. Having it continuously invert in a loop also doesn't work, as it will invert already inverted parts.

I also tried RedrawWindow in combination with BitBlt in a loop in order to redraw the parts I would need to invert, and while it does successfully redraw the window and invert it, it results in some pretty bad flickering.

My current code:

RedrawWindow(hwnd, NULL, NULL, RDW_UPDATENOW | RDW_INVALIDATE);

BitBlt(
        GetDC(hwnd),
        300, 100,
        600, 500,
        NULL,
        0, 0,
        DSTINVERT
);

Example of what I want to achieve:

Image

0 Answers
Related