ScriptDithering.cpp
1 |
/*********************************************************************************** |
2 |
ImAnalyse : software in image processing and image analysis |
3 |
|
4 |
Copyright (C) 27 avril 2008 <Vincent MORARD> |
5 |
Version: 2.0 |
6 |
Contact: vincent<POINT>morard<AROBAS>cpe<POINT>fr |
7 |
Website: http://pistol.petesampras.free.fr |
8 |
|
9 |
This program is free software: you can redistribute it and/or modify |
10 |
it under the terms of the GNU General Public License as published by |
11 |
the Free Software Foundation, either version 3 of the License, or |
12 |
(at your option) any later version. |
13 |
|
14 |
This program is distributed in the hope that it will be useful, |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 |
GNU General Public License for more details. |
18 |
|
19 |
You should have received a copy of the GNU General Public License |
20 |
along with this program. If not, see <http://www.gnu.org/licenses/ |
21 |
**********************************************************************************/ |
22 |
#include "../CImage.h" |
23 |
#include "../DlgCallback.h" |
24 |
void Message22(HWND hList,HWND hDlg,char *Mes,int Buf) |
25 |
{ |
26 |
SendMessage(hList,LB_ADDSTRING, 0, (LPARAM)Mes); |
27 |
SendMessage(hDlg,WM_UPDATE,Buf,0); |
28 |
Sleep(100); |
29 |
} |
30 |
|
31 |
|
32 |
|
33 |
DWORD WINAPI Script_Dithering_1(LPVOID lpParam ) |
34 |
{ |
35 |
HWND hDlg,hOK,hwndList; |
36 |
Param *P; |
37 |
P=(Param*)lpParam; |
38 |
hDlg=(HWND) P->hwnd; |
39 |
int NbLevel=P->Data1; |
40 |
|
41 |
|
42 |
hwndList=GetDlgItem(hDlg, IDC_LIST1); |
43 |
hOK=GetDlgItem(hDlg, IDOK); |
44 |
|
45 |
|
46 |
int t = GetTickCount(); //initialisation du temps |
47 |
char szName[100],szBuf[10]; |
48 |
SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)"Début du traitement"); |
49 |
|
50 |
char szExe[_MAX_PATH],*Q=szExe; |
51 |
GetModuleFileName(NULL,szExe,_MAX_PATH); |
52 |
while(*Q!=0)Q++; |
53 |
while(*Q!='\\')Q--;*Q=0; |
54 |
strcat(szExe,"\\Fleur.jpg"); |
55 |
if(Img[0].LoadJPG_GIF(szExe)==0)return 0; |
56 |
|
57 |
Message22(hwndList,hDlg,"Ouverture de l'image :Fait",0); |
58 |
|
59 |
int Level[8]; |
60 |
Level[0]=0; |
61 |
Level[1]=255; |
62 |
|
63 |
Level[2]=128; |
64 |
|
65 |
Level[3]=64; |
66 |
Level[4]=192; |
67 |
|
68 |
Level[5]=32; |
69 |
Level[6]=96; |
70 |
Level[7]=160; |
71 |
|
72 |
|
73 |
for(int i=0;i<7;i++) |
74 |
{ |
75 |
t = GetTickCount(); |
76 |
Img[0].Dithering(RGBi,i,Level,NbLevel,&Img[i+1]); |
77 |
t = GetTickCount() - t; |
78 |
|
79 |
switch(i) |
80 |
{ |
81 |
case 0:strcpy(szName,"Nearest : ");break; |
82 |
case 1:strcpy(szName,"Floyd_Steinberg : ");break; |
83 |
case 2:strcpy(szName,"Bill Atkinson : ");break; |
84 |
case 3:strcpy(szName,"Jarvis_Judice_Ninke : ");break; |
85 |
case 4:strcpy(szName,"Stucki : ");break; |
86 |
case 5:strcpy(szName,"Burkes : ");break; |
87 |
case 6:strcpy(szName,"Morard : ");break; |
88 |
|
89 |
} |
90 |
|
91 |
Message22(hwndList,hDlg,strcat(szName,itoa(t,szBuf,10)),i+1); |
92 |
|
93 |
|
94 |
} |
95 |
|
96 |
|
97 |
|
98 |
EnableWindow(hOK,TRUE); |
99 |
return 1; |
100 |
|
101 |
} |
102 |
|
103 |
DWORD WINAPI Script_Dithering_2(LPVOID lpParam ) |
104 |
{ |
105 |
HWND hDlg,hOK,hwndList; |
106 |
Param *P; |
107 |
P=(Param*)lpParam; |
108 |
hDlg=(HWND) P->hwnd; |
109 |
int NbLevel=P->Data1; |
110 |
|
111 |
|
112 |
hwndList=GetDlgItem(hDlg, IDC_LIST1); |
113 |
hOK=GetDlgItem(hDlg, IDOK); |
114 |
|
115 |
|
116 |
int t = GetTickCount(); //initialisation du temps |
117 |
char szName[100],szBuf[10]; |
118 |
SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)"Début du traitement"); |
119 |
|
120 |
char szExe[_MAX_PATH],*Q=szExe; |
121 |
GetModuleFileName(NULL,szExe,_MAX_PATH); |
122 |
while(*Q!=0)Q++; |
123 |
while(*Q!='\\')Q--;*Q=0; |
124 |
strcat(szExe,"\\KewGarden.jpg"); |
125 |
if(Img[0].LoadJPG_GIF(szExe)==0)return 0; |
126 |
Message22(hwndList,hDlg,"Ouverture de l'image :Fait",0); |
127 |
|
128 |
int Level[8]; |
129 |
Level[0]=0; |
130 |
Level[1]=255; |
131 |
|
132 |
Level[2]=128; |
133 |
|
134 |
Level[3]=64; |
135 |
Level[4]=192; |
136 |
|
137 |
Level[5]=32; |
138 |
Level[6]=96; |
139 |
Level[7]=160; |
140 |
|
141 |
|
142 |
for(int i=0;i<7;i++) |
143 |
{ |
144 |
t = GetTickCount(); |
145 |
Img[0].Dithering(GRAY,i,Level,NbLevel,&Img[i+1]); |
146 |
t = GetTickCount() - t; |
147 |
|
148 |
switch(i) |
149 |
{ |
150 |
case 0:strcpy(szName,"Nearest : ");break; |
151 |
case 1:strcpy(szName,"Floyd_Steinberg : ");break; |
152 |
case 2:strcpy(szName,"Bill Atkinson : ");break; |
153 |
case 3:strcpy(szName,"Jarvis_Judice_Ninke : ");break; |
154 |
case 4:strcpy(szName,"Stucki : ");break; |
155 |
case 5:strcpy(szName,"Burkes : ");break; |
156 |
case 6:strcpy(szName,"Morard : ");break; |
157 |
|
158 |
} |
159 |
|
160 |
Message22(hwndList,hDlg,strcat(szName,itoa(t,szBuf,10)),i+1); |
161 |
|
162 |
|
163 |
} |
164 |
|
165 |
|
166 |
|
167 |
EnableWindow(hOK,TRUE); |
168 |
return 1; |
169 |
|
170 |
} |
lien1 lien2 lien3