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 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static const int w = 150;
static const int h = 150;
static COLORREF s_pixels[w * h] = {0};
switch (uMsg)
{
case WM_CREATE: {
COLORREF crefs[] = {
RGB(255, 0, 0),
RGB(0, 255, 0),
RGB(0, 0, 255),
RGB(0, 0, 0)
};
for(int i = 0; i < w; ++i) {
for(int j = 0; j < h; ++j) {
s_pixels[i * w + j] = interpolateColors(crefs, w, h, i, j);
}
}
}
break;
case WM_DESTROY: {
PostQuitMessage(0);
}
break;
case WM_PAINT: {
PAINTSTRUCT ps = {0};
HDC hdc = BeginPaint(hWnd, &ps);
int x = 50;
int y = 50;
for(int i = 0; i < w; ++i) {
for(int j = 0; j < h; ++j) {
COLORREF cref3 = s_pixels[i * w + j];
SetPixel(hdc, x + i, y + j, cref3);
}
}
EndPaint(hWnd, &ps);
}
break;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return 0;
}
|