The SetPixel function sets the pixel at the specified coordinates to the specified color. COLORREF SetPixel( HDC hdc, // handle to DC int X, // x-coordinate of pixel int Y, // y-coordinate of pixel COLORREF crColor // pixel color );
HDC hdc; hdc = CreateDC("DISPLAY",NULL,NULL,NULL); for (int i=-4; i<4 ;i++) for (int j=-4 ;j<4 ;j++) { SetPixel(hdc,100 +i,100+j,RGB(0,0,255)); }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question#include <windows.h> int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HDC hdc; hdc = CreateDC("DISPLAY",NULL,NULL,NULL); srand(GetTickCount()); DWORD deb = GetTickCount(); DWORD fin = GetTickCount(); while (fin-deb<1500) { int x = rand() % GetSystemMetrics(SM_CXSCREEN); int y = rand() % GetSystemMetrics(SM_CYSCREEN); int r = rand() %256; int g = rand() %256; int b = rand() %256; SetPixel(hdc,x,y,RGB(r,g,b)); deb = GetTickCount(); } DeleteDC(hdc); return 0; }