MCPcopy Create free account
hub / github.com/DiscordMessenger/dm / DrawIconInvert

Function DrawIconInvert

src/windows/WinUtils.cpp:1560–1583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1558}
1559
1560void DrawIconInvert(HDC hdc, HICON hIcon, int x, int y, int sizeX, int sizeY, bool invert)
1561{
1562 if (!invert) {
1563 ri::DrawIconEx(hdc, x, y, hIcon, sizeX, sizeY, 0, NULL, DI_NORMAL | DI_COMPAT);
1564 return;
1565 }
1566
1567 HDC hdcMem = CreateCompatibleDC(hdc);
1568 HBITMAP hbm = CreateCompatibleBitmap(hdc, sizeX, sizeY);
1569 HGDIOBJ oldObj = SelectObject(hdcMem, hbm);
1570
1571 // take the contents of the HDC there and invert them.
1572 BitBlt(hdcMem, 0, 0, sizeX, sizeY, hdc, x, y, NOTSRCCOPY);
1573
1574 ri::DrawIconEx(hdcMem, 0, 0, hIcon, sizeX, sizeY, 0, NULL, DI_NORMAL | DI_COMPAT);
1575
1576 // now blit it back out inverted
1577 BitBlt(hdc, x, y, sizeX, sizeY, hdcMem, 0, 0, NOTSRCCOPY);
1578
1579 // clean up
1580 SelectObject(hdcMem, oldObj);
1581 DeleteBitmap(hbm);
1582 DeleteDC(hdcMem);
1583}
1584
1585// Resizes a transparent image with a transparent color, without looking bad.
1586// NOTE: Creates a new bitmap. Make sure to delete the bitmap when done.

Callers 2

DrawButtonMethod · 0.85
WndProcMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected