Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question#include <windows.h> #define APPNAME "SIW" #define CAPTION "SIW - Essai" #include struct RGBTrip { unsigned char _b; unsigned char _g; unsigned char _r; //unsigned char _dummy; }; #include // les infos pour notre "image" RGBTrip g_data[100*100]; BITMAPINFO myBitmapInfo; long WINAPI WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hDc; switch(message) { case WM_PAINT: { hDc = BeginPaint(hWnd, &ps); BOOL res=StretchDIBits(hDc, 20, 20, 100, 100, 0, 0, 100, 100, (void *)g_data, &myBitmapInfo, DIB_RGB_COLORS, SRCCOPY); EndPaint(hWnd, &ps); break; } case WM_DESTROY: PostQuitMessage(0); return 0; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { WNDCLASS wc; HWND hwnd; MSG msg; wc.style = CS_HREDRAW|CS_VREDRAW; wc.lpfnWndProc = WindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(0, IDI_APPLICATION); wc.hCursor = LoadCursor(0, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = 0; wc.lpszClassName = APPNAME; RegisterClass(&wc); hwnd = CreateWindow(APPNAME, CAPTION, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, hInstance, 0); memset(&myBitmapInfo, 0, sizeof(myBitmapInfo)); myBitmapInfo.bmiHeader.biBitCount = 24; myBitmapInfo.bmiHeader.biCompression = BI_RGB; myBitmapInfo.bmiHeader.biHeight = 100; myBitmapInfo.bmiHeader.biWidth = 100; myBitmapInfo.bmiHeader.biPlanes = 1; myBitmapInfo.bmiHeader.biSizeImage = 0; myBitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); myBitmapInfo.bmiHeader.biClrUsed = 0; myBitmapInfo.bmiHeader.biClrImportant = 0; RGBTrip c = { 0, 0, 255}; for(int y = 0; y<100; y++) { for(int x = 0; x<100; x++) { g_data[x+y*100] = c; } } ShowWindow(hwnd, nShowCmd); UpdateWindow(hwnd); while(GetMessage(&msg, 0, 0, 0) == TRUE) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }