/////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <windows.h>
#include <stdlib.h>
#include <time.h>
#include "resource1.h"
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
HINSTANCE g_hInst;
LPCTSTR lpszClass = TEXT("Menu");
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdParam, int nCmdShow)
{
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
g_hInst = hInstance;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClass.hInstance = hInstance;
WndClass.lpfnWndProc = WndProc;
WndClass.lpszClassName = lpszClass;
WndClass.lpszMenuName = NULL;
WndClass.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&WndClass);
hWnd = CreateWindow(lpszClass, lpszClass, WS_OVERLAPPEDWINDOW, 300, 200, 140, 200, NULL, (HMENU)NULL, hInstance, NULL);
ShowWindow(hWnd, nCmdShow);
while (GetMessage(&Message, NULL, 0, 0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return (int)Message.wParam;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM IParam)
{
int x, y;
static COLORREF cr[128][256];
time_t mytime;
static HANDLE hTimer1, hTimer2, hTimer3, hTimer4, hTimer5, hTimer6, hTimer7, hTimer8
, hTimer9, hTimer10, hTimer11;
PAINTSTRUCT ps;
HBITMAP MyBitmap, OldBitmap;
HDC hdc, MemDC;
switch(iMessage){
case WM_LBUTTONDOWN:
hdc = GetDC(hWnd);
MemDC = CreateCompatibleDC(hdc);
MyBitmap = LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_BITMAP1));
OldBitmap = (HBITMAP)SelectObject(MemDC, MyBitmap);
BitBlt(hdc, 0, 0, 123, 160, MemDC, 0, 0, SRCCOPY);
SelectObject(MemDC, OldBitmap);
DeleteObject(MyBitmap);
for (int i = 0; i < 119; i++)
for (int j = 0; j < 163; j++)
cr[i][j] = GetPixel(hdc, i + 1, j + 1);
InvalidateRect(hWnd, NULL, TRUE);
ReleaseDC(hWnd, hdc);
break;
case WM_CREATE:
hTimer1 = (HANDLE)SetTimer(hWnd, 1, 0, NULL);
//hTimer2 = (HANDLE)SetTimer(hWnd, 2, 0, NULL);
//hTimer3 = (HANDLE)SetTimer(hWnd, 3, 0, NULL);
//hTimer4 = (HANDLE)SetTimer(hWnd, 4, 0, NULL);
//hTimer5 = (HANDLE)SetTimer(hWnd, 5, 0, NULL);
case WM_TIMER:
switch (wParam) {
case 1:
x = rand() % 119;
y = rand() % 163;
time(&mytime);
hdc = GetDC(hWnd);
SetPixelV(hdc, x, y, cr[x][y]);
x = rand() % 119;
y = rand() % 163;
time(&mytime);
hdc = GetDC(hWnd);
x = rand() % 119;
y = rand() % 163;
time(&mytime);
hdc = GetDC(hWnd);
x = rand() % 119;
y = rand() % 163;
time(&mytime);
hdc = GetDC(hWnd);
x = rand() % 119;
y = rand() % 163;
time(&mytime);
hdc = GetDC(hWnd);
SetPixelV(hdc, x, y, cr[x][y]);
x = rand() % 119;
y = rand() % 163;
time(&mytime);
hdc = GetDC(hWnd);
SetPixelV(hdc, x, y, cr[x][y]);
SetPixelV(hdc, x, y, cr[x][y]);
SetPixelV(hdc, x, y, cr[x][y]);
SetPixelV(hdc, x, y, cr[x][y]);
ReleaseDC(hWnd, hdc);
break;
case 2:
time(&mytime);
hdc = GetDC(hWnd);
for (int i = 0; i < 35000; i++)
SetPixel(hdc, rand() % 123, rand() % 160, 0x0);
ReleaseDC(hWnd, hdc);
break;
case 3:
time(&mytime);
hdc = GetDC(hWnd);
for (int i = 0; i < 35000; i++)
SetPixel(hdc, rand() % 123, rand() % 160, 0x0);
ReleaseDC(hWnd, hdc);
break;
case 4:
time(&mytime);
hdc = GetDC(hWnd);
MemDC = CreateCompatibleDC(hdc);
MyBitmap = LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_BITMAP1));
OldBitmap = (HBITMAP)SelectObject(MemDC, MyBitmap);
BitBlt(hdc, 0, 0, 123, 160, MemDC, 0, 0, SRCCOPY);
SelectObject(MemDC, OldBitmap);
DeleteObject(MyBitmap);
ReleaseDC(hWnd, hdc);
break;
case 5:
break;
}
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return(DefWindowProc(hWnd, iMessage, wParam, IParam));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
사진픽셀값불러와서
랜덤으로 뿌려주는건데
좀뿌리다 렉처먹네
타이머1 잘못복붙