Accueil > > > DEGRADÉ DE COULEUR
DEGRADÉ DE COULEUR
Information sur la source
Description
Voila un programme qui affiche un degradé de couleur. Bon l'algorithme est le plus bourrin qu'il soit !
Source
- //***********************************************
- #include <windows.h>
- #include "resource.h"
-
- LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
- //***********************************************
-
- int WINAPI WinMain(
- HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- PSTR szCmdLine,
- int iCmdShow
- )
- {
- static char szAppName[] = "Couleur";
- HWND hwnd;
- MSG msg;
- WNDCLASSEX wndclass;
-
- wndclass.cbSize = sizeof (wndclass);
- wndclass.style = 0;
- wndclass.lpfnWndProc = WndProc;
- wndclass.cbClsExtra = 0;
- wndclass.cbWndExtra = 0;
- wndclass.hInstance = hInstance;
- wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
- wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
- wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
- wndclass.lpszMenuName = NULL;
- wndclass.lpszClassName = szAppName;
- wndclass.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
-
- RegisterClassEx(&wndclass);
-
- hwnd = CreateWindow(
- szAppName, // nom de la classe
- szAppName, // titre de la fenetre
- WS_OVERLAPPED | WS_SYSMENU, // style de la fenetre
- CW_USEDEFAULT, // position initiale en x
- CW_USEDEFAULT, // position initiale en y
- 512, // largeur initiale
- 512, // hauteur initiale
- NULL, // handle de la fenetre mere
- NULL, // handle du menu de la fenetre
- hInstance, // handle de l'instance
- NULL); // parametres de creation
-
- ShowWindow(hwnd,iCmdShow);
- UpdateWindow(hwnd);
-
- while(GetMessage(&msg,NULL,0,0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return msg.wParam;
- }
-
- LRESULT CALLBACK WndProc(
- HWND hwnd,
- UINT iMsg,
- WPARAM wParam,
- LPARAM lParam
- )
- {
-
- switch (iMsg)
- {
- case WM_CREATE:
- {
- return 0;
- }
- case WM_PAINT:
- {
- HDC hdc;
- PAINTSTRUCT ps;
- RECT rect;
- int x,y;
-
- hdc = BeginPaint(hwnd,&ps);
- GetClientRect(hwnd,&rect);
- // les carres sont disposes comme ci-dessous
- // 1 2
- // 3 4
- //
- // 1
- for(x=rect.left;x<256;x++)
- {
- for(y=rect.top;y<256;y++)
- {
- SetPixel(hdc,x,y,RGB(x & 255,0,y & 255));
- }
- }
- // 2
- for(x=max(rect.left,256);x<512;x++)
- {
- for(y=rect.top;y<256;y++)
- {
- SetPixel(hdc,x,y,RGB(~(x & 255),0,y & 255));
- }
- }
- // 3
- for(x=rect.left;x<256;x++)
- {
- for(y=max(rect.top,256);y<512;y++)
- {
- SetPixel(hdc,x,y,RGB(x & 255,0,~(y & 255)));
- }
- }
- // 4
- for(x=max(rect.left,256);x<512;x++)
- {
- for(y=max(rect.top,256);y<512;y++)
- {
- SetPixel(hdc,x,y,RGB(~(x & 255),0,~(y & 255)));
- }
- }
-
- EndPaint(hwnd,&ps);
- return 0;
- }
- case WM_COMMAND:
- {
- break;
- }
- case WM_DESTROY:
- {
- PostQuitMessage (0);
- return 0;
- }
- }
-
- return DefWindowProc(hwnd,iMsg,wParam,lParam);
- }
//***********************************************
#include <windows.h>
#include "resource.h"
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
//***********************************************
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PSTR szCmdLine,
int iCmdShow
)
{
static char szAppName[] = "Couleur";
HWND hwnd;
MSG msg;
WNDCLASSEX wndclass;
wndclass.cbSize = sizeof (wndclass);
wndclass.style = 0;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
wndclass.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
RegisterClassEx(&wndclass);
hwnd = CreateWindow(
szAppName, // nom de la classe
szAppName, // titre de la fenetre
WS_OVERLAPPED | WS_SYSMENU, // style de la fenetre
CW_USEDEFAULT, // position initiale en x
CW_USEDEFAULT, // position initiale en y
512, // largeur initiale
512, // hauteur initiale
NULL, // handle de la fenetre mere
NULL, // handle du menu de la fenetre
hInstance, // handle de l'instance
NULL); // parametres de creation
ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(
HWND hwnd,
UINT iMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch (iMsg)
{
case WM_CREATE:
{
return 0;
}
case WM_PAINT:
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
int x,y;
hdc = BeginPaint(hwnd,&ps);
GetClientRect(hwnd,&rect);
// les carres sont disposes comme ci-dessous
// 1 2
// 3 4
//
// 1
for(x=rect.left;x<256;x++)
{
for(y=rect.top;y<256;y++)
{
SetPixel(hdc,x,y,RGB(x & 255,0,y & 255));
}
}
// 2
for(x=max(rect.left,256);x<512;x++)
{
for(y=rect.top;y<256;y++)
{
SetPixel(hdc,x,y,RGB(~(x & 255),0,y & 255));
}
}
// 3
for(x=rect.left;x<256;x++)
{
for(y=max(rect.top,256);y<512;y++)
{
SetPixel(hdc,x,y,RGB(x & 255,0,~(y & 255)));
}
}
// 4
for(x=max(rect.left,256);x<512;x++)
{
for(y=max(rect.top,256);y<512;y++)
{
SetPixel(hdc,x,y,RGB(~(x & 255),0,~(y & 255)));
}
}
EndPaint(hwnd,&ps);
return 0;
}
case WM_COMMAND:
{
break;
}
case WM_DESTROY:
{
PostQuitMessage (0);
return 0;
}
}
return DefWindowProc(hwnd,iMsg,wParam,lParam);
}
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Arnault Nouvel et Antoine Dongois Le processus à prendre : Apprendre (découvrir la plateforme) Préparer (documenter l'historique et choisir la méthode de MAJ) Test (Test de MAJ) Implémenter (Effectuer la MAJ) Valid...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOURTECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOUR par ROMELARD Fabrice
Après un retour sur l'histoire des TechDays de Paris et le fait que ce soit le plus gros event MS au monde (du fait de sa gratuité), le président de MS France (Eric Boustoullier) a fait une présentation de la vision Microsoft pour les années à venir...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|