-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbetterrgbquad.cpp
38 lines (36 loc) · 1.03 KB
/
betterrgbquad.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <windows.h>
typedef union _RGBQUAD {
COLORREF rgb;
struct {
BYTE b;
BYTE g;
BYTE r;
BYTE unused;
};
} *PRGBQUAD;
DWORD WINAPI shader1(LPVOID lpParam) {
int w = GetSystemMetrics(0), h = GetSystemMetrics(1);
_RGBQUAD* data = (_RGBQUAD*)VirtualAlloc(0, (w * h + w) * sizeof(_RGBQUAD), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
for (int i = 0;; i++, i %= 3) {
HDC desk = GetDC(NULL);
HDC hdcdc = CreateCompatibleDC(desk);
HBITMAP hbm = CreateBitmap(w, h, 1, 32, data);
SelectObject(hdcdc, hbm);
BitBlt(hdcdc, 0, 0, w, h, desk, 0, 0, SRCCOPY);
GetBitmapBits(hbm, w * h * 4, data);
for (int i = 0; w * h > i; i++) {
int x = i % w, y = i / h, t = y ^ y | x;
data[i].rgb = x & y & t;
}
SetBitmapBits(hbm, w * h * 4, data);
BitBlt(desk, 0, 0, w, h, hdcdc, 0, 0, SRCCOPY);
DeleteObject(hbm);
DeleteObject(hdcdc);
DeleteObject(desk);
}
return 0;
}
int main() {
CreateThread(0, 0, shader1, 0, 0, 0);
Sleep(-1);
}