Rev 7929 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7929 | IgorA | 1 | ; |
2 | ; файл для работы с выделенными точками, |
||
3 | ; по которым делается преобразование изображения |
||
4 | ;[0-3] - рамка (исх. и.) |
||
5 | ;[4] - средняя точка (исх. и.) |
||
6 | ;[5-6] - рамка (вых. и.) |
||
7 | ;[7] - средняя точка (вых. и.) |
||
8 | ; |
||
9 | |||
10 | struct point2d |
||
11 | x dd ? ;координата относит изображения |
||
12 | y dd ? |
||
13 | tx dd ? ;координата для текстуры |
||
14 | ty dd ? |
||
15 | captx rb 6 |
||
16 | capty rb 6 |
||
17 | ends |
||
18 | |||
19 | ;настройка точек при загрузке программы |
||
20 | ;(точки не активны) |
||
21 | align 4 |
||
22 | points_init: |
||
23 | xor eax,eax |
||
24 | dec eax |
||
25 | mov ecx,8 |
||
26 | mov edi,sel_pt |
||
27 | @@: |
||
28 | mov [edi+point2d.x],eax |
||
29 | mov [edi+point2d.y],eax |
||
30 | add edi,sizeof.point2d |
||
31 | loop @b |
||
32 | ret |
||
33 | |||
34 | ;настройка точек при открытии изображения |
||
35 | ;(точки ставятся по углам изображения) |
||
36 | align 4 |
||
7986 | IgorA | 37 | proc points_init_2 uses eax ecx edx edi, ot_x:dword, ot_y:dword |
38 | mov eax,[ot_y] |
||
7929 | IgorA | 39 | mov edi,sel_pt |
40 | mov edx,[ot_x] |
||
41 | mov [edi+point2d.x],edx ;1 |
||
42 | mov [edi+point2d.y],eax ;1 |
||
43 | add edi,sizeof.point2d |
||
44 | mov ecx,[buf_i0.w] |
||
45 | sub ecx,edx |
||
46 | mov [edi+point2d.x],ecx ;2 |
||
47 | mov [edi+point2d.y],eax ;2 |
||
48 | add edi,sizeof.point2d |
||
49 | mov [edi+point2d.x],ecx ;3 |
||
50 | mov ecx,[buf_i0.h] |
||
7986 | IgorA | 51 | sub ecx,eax |
7929 | IgorA | 52 | mov [edi+point2d.y],ecx ;3 |
53 | add edi,sizeof.point2d |
||
54 | mov [edi+point2d.x],edx ;4 |
||
55 | mov [edi+point2d.y],ecx ;4 |
||
56 | call points_update_prop |
||
57 | ret |
||
58 | endp |
||
59 | |||
60 | align 4 |
||
61 | proc points_update_prop uses eax ebx ecx edi esi |
||
62 | ;вычисление координат средней точки |
||
63 | mov edi,sel_pt |
||
64 | xor eax,eax |
||
65 | xor ebx,ebx |
||
66 | mov ecx,4 |
||
67 | @@: |
||
68 | add eax,[edi+point2d.x] |
||
69 | add ebx,[edi+point2d.y] |
||
70 | add edi,sizeof.point2d |
||
71 | loop @b |
||
72 | shr eax,2 |
||
73 | mov [edi+point2d.x],eax |
||
74 | shr ebx,2 |
||
75 | mov [edi+point2d.y],ebx |
||
76 | add edi,sizeof.point2d |
||
77 | |||
78 | cmp byte[trans_a],0 ;проверяем алгоритм растягивания текстуры |
||
79 | je @f |
||
80 | ;на весь буфер |
||
81 | xor eax,eax |
||
82 | mov ebx,edi |
||
83 | mov edi,buf_i0 |
||
84 | mov [ebx+point2d.x],eax |
||
85 | mov [ebx+point2d.y],eax |
||
86 | add ebx,sizeof.point2d |
||
87 | mov eax,buf2d_w |
||
88 | mov [ebx+point2d.x],eax |
||
89 | mov ecx,buf2d_h |
||
90 | mov [ebx+point2d.y],ecx |
||
91 | add ebx,sizeof.point2d |
||
92 | shr eax,1 |
||
93 | mov [ebx+point2d.x],eax |
||
94 | shr ecx,1 |
||
95 | mov [ebx+point2d.y],ecx |
||
96 | jmp .end0 |
||
97 | @@: |
||
98 | ;на часть буфера |
||
99 | mov eax,[edi+point2d.x-5*sizeof.point2d] |
||
100 | add eax,[edi+point2d.x-2*sizeof.point2d] |
||
101 | shr eax,1 |
||
102 | mov [edi+point2d.x],eax |
||
103 | mov eax,[edi+point2d.x-4*sizeof.point2d] |
||
104 | add eax,[edi+point2d.x-3*sizeof.point2d] |
||
105 | shr eax,1 |
||
106 | mov [edi+point2d.x+sizeof.point2d],eax |
||
107 | |||
108 | mov eax,[edi+point2d.y-5*sizeof.point2d] |
||
109 | add eax,[edi+point2d.y-4*sizeof.point2d] |
||
110 | shr eax,1 |
||
111 | mov [edi+point2d.y],eax |
||
112 | mov eax,[edi+point2d.y-3*sizeof.point2d] |
||
113 | add eax,[edi+point2d.y-2*sizeof.point2d] |
||
114 | shr eax,1 |
||
115 | mov [edi+point2d.y+sizeof.point2d],eax |
||
116 | |||
117 | lea esi,[edi-sizeof.point2d] |
||
118 | add edi,2*sizeof.point2d |
||
119 | movsd ;copy coord x |
||
120 | movsd ;copy coord y |
||
121 | .end0: |
||
122 | |||
123 | mov edi,buf_i0 |
||
124 | mov ebx,sel_pt |
||
125 | mov ecx,8 |
||
126 | finit |
||
127 | .cycle0: |
||
128 | fild dword[ebx+point2d.x] |
||
129 | fidiv buf2d_w |
||
130 | fst dword[ebx+point2d.tx] |
||
131 | |||
132 | fstp qword[Data_Double] |
||
133 | call DoubleFloat_to_String |
||
134 | call String_crop_0 |
||
135 | m2m dword[ebx+point2d.captx],dword[Data_String] |
||
136 | mov al,byte[Data_String+4] |
||
137 | mov byte[ebx+point2d.captx+4],al |
||
138 | |||
139 | fild dword[ebx+point2d.y] |
||
140 | fidiv buf2d_h |
||
141 | fst dword[ebx+point2d.ty] |
||
142 | |||
143 | fstp qword[Data_Double] |
||
144 | call DoubleFloat_to_String |
||
145 | call String_crop_0 |
||
146 | m2m dword[ebx+point2d.capty],dword[Data_String] |
||
147 | mov al,byte[Data_String+4] |
||
148 | mov byte[ebx+point2d.capty+4],al |
||
149 | |||
150 | add ebx,sizeof.point2d |
||
151 | loop .cycle0 |
||
152 | |||
153 | call draw_transf_texture |
||
154 | ret |
||
155 | endp |
||
156 | |||
157 | ;рисование выбранных точек |
||
158 | align 4 |
||
159 | proc points_draw |
||
160 | locals |
||
161 | PervX dd 0 ;pervios point coord X |
||
162 | PervY dd 0 ;pervios point coord Y |
||
163 | GrafX dd ? ;active point coord X |
||
164 | GrafY dd ? ;active point coord Y |
||
165 | endl |
||
166 | mov edi,buf_ogl |
||
167 | cmp buf2d_data,0 |
||
168 | je .endf |
||
169 | |||
170 | xor ecx,ecx |
||
171 | mov edi,sel_pt |
||
172 | mov dword[txt_buf],'0' |
||
173 | |||
174 | cmp byte[view_b],1 |
||
175 | je .cycle0end |
||
176 | ;берем координаты последней точки |
||
177 | mov eax,[edi+3*sizeof.point2d+point2d.x] |
||
178 | add eax,[nav_x] |
||
179 | mov [PervX],eax |
||
180 | mov ebx,[edi+3*sizeof.point2d+point2d.y] |
||
181 | add ebx,[nav_y] |
||
182 | mov [PervY],ebx |
||
183 | align 4 |
||
184 | .cycle0: |
||
185 | cmp dword[edi+point2d.x],-1 |
||
186 | je .end0 |
||
187 | mov eax,[edi+point2d.x] |
||
188 | add eax,[nav_x] |
||
189 | mov [GrafX],eax |
||
190 | sub eax,3 |
||
191 | mov ebx,[edi+point2d.y] |
||
192 | add ebx,[nav_y] |
||
193 | mov [GrafY],ebx |
||
194 | sub ebx,3 |
||
195 | cmp ecx,[sel_act] |
||
196 | je @f |
||
197 | stdcall [buf2d_filled_rect_by_size], buf_0, eax,ebx, 5,5, 0xffff00 |
||
198 | @@: |
||
199 | dec eax |
||
200 | dec ebx |
||
201 | stdcall [buf2d_rect_by_size], buf_0, eax,ebx, 7,7, 0x808000 |
||
202 | call point_draw_info |
||
203 | ;рисование линии |
||
204 | stdcall [buf2d_line], buf_0, [PervX],[PervY], [GrafX],[GrafY], 0x808000 |
||
205 | mov eax,[GrafX] |
||
206 | mov [PervX],eax |
||
207 | mov eax,[GrafY] |
||
208 | mov [PervY],eax |
||
209 | .end0: |
||
210 | add edi,sizeof.point2d |
||
211 | inc ecx |
||
212 | cmp ecx,4 |
||
213 | jl .cycle0 |
||
214 | jmp .cycle1end |
||
215 | .cycle0end: |
||
216 | add edi,5*sizeof.point2d |
||
217 | align 4 |
||
218 | .cycle1: |
||
219 | cmp dword[edi+point2d.x],-1 |
||
220 | je .end1 |
||
221 | mov eax,[GrafX] |
||
222 | mov [PervX],eax |
||
223 | mov eax,[GrafY] |
||
224 | mov [PervY],eax |
||
225 | mov eax,[edi+point2d.x] |
||
226 | add eax,[nav_x] |
||
227 | mov [GrafX],eax |
||
228 | sub eax,3 |
||
229 | mov ebx,[edi+point2d.y] |
||
230 | add ebx,[nav_y] |
||
231 | mov [GrafY],ebx |
||
232 | sub ebx,3 |
||
233 | stdcall [buf2d_filled_rect_by_size], buf_0, eax,ebx, 5,5, 0xffff00 |
||
234 | dec eax |
||
235 | dec ebx |
||
236 | stdcall [buf2d_rect_by_size], buf_0, eax,ebx, 7,7, 0x808000 |
||
237 | call point_draw_info |
||
238 | .end1: |
||
239 | add edi,sizeof.point2d |
||
240 | inc ecx |
||
241 | cmp ecx,2 |
||
242 | jl .cycle1 |
||
243 | mov eax,[GrafX] |
||
244 | sub eax,[PervX] |
||
245 | mov [GrafX],eax |
||
246 | mov eax,[GrafY] |
||
247 | sub eax,[PervY] |
||
248 | mov [GrafY],eax |
||
249 | stdcall [buf2d_rect_by_size], buf_0, [PervX],[PervY], [GrafX],[GrafY], 0x808000 |
||
250 | .cycle1end: |
||
251 | ;средняя точка |
||
252 | mov eax,[edi+point2d.x] |
||
253 | add eax,[nav_x] |
||
254 | sub eax,3 |
||
255 | mov ebx,[edi+point2d.y] |
||
256 | add ebx,[nav_y] |
||
257 | sub ebx,3 |
||
258 | stdcall [buf2d_filled_rect_by_size], buf_0, eax,ebx, 5,5, 0xff0000 |
||
259 | dec eax |
||
260 | dec ebx |
||
261 | stdcall [buf2d_rect_by_size], buf_0, eax,ebx, 7,7, 0x808000 |
||
262 | add ebx,9 |
||
263 | inc byte[txt_buf] |
||
264 | stdcall [buf2d_draw_text], buf_0, buf_font,txt_buf,eax,ebx,0 |
||
265 | .endf: |
||
266 | ret |
||
267 | endp |
||
268 | |||
269 | ;input: |
||
270 | ; eax - coord x |
||
271 | ; ebx - coord y |
||
272 | ; edi - указатель на структуру point2d |
||
273 | align 4 |
||
274 | point_draw_info: |
||
275 | ;вывод текста |
||
276 | add ebx,9 |
||
277 | inc byte[txt_buf] |
||
278 | inc eax |
||
279 | stdcall [buf2d_draw_text], buf_0, buf_font,txt_buf,eax,ebx,0xffffff |
||
280 | sub eax,2 |
||
281 | stdcall [buf2d_draw_text], buf_0, buf_font,txt_buf,eax,ebx,0xffffff |
||
282 | inc eax |
||
283 | inc ebx |
||
284 | stdcall [buf2d_draw_text], buf_0, buf_font,txt_buf,eax,ebx,0xffffff |
||
285 | ;dec ebx |
||
286 | sub ebx,2 |
||
287 | stdcall [buf2d_draw_text], buf_0, buf_font,txt_buf,eax,ebx,0xffffff |
||
288 | inc ebx |
||
289 | stdcall [buf2d_draw_text], buf_0, buf_font,txt_buf,eax,ebx,0 |
||
290 | add ebx,9 |
||
291 | lea edx,[edi+point2d.captx] |
||
292 | inc eax |
||
293 | stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0xffffff |
||
294 | sub eax,2 |
||
295 | stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0xffffff |
||
296 | inc eax |
||
297 | inc ebx |
||
298 | stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0xffffff |
||
299 | ;dec ebx |
||
300 | sub ebx,2 |
||
301 | stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0xffffff |
||
302 | inc ebx |
||
303 | stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0 |
||
304 | add ebx,9 |
||
305 | lea edx,[edi+point2d.capty] |
||
306 | inc eax |
||
307 | stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0xffffff |
||
308 | sub eax,2 |
||
309 | stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0xffffff |
||
310 | inc eax |
||
311 | inc ebx |
||
312 | stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0xffffff |
||
313 | ;dec ebx |
||
314 | sub ebx,2 |
||
315 | stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0xffffff |
||
316 | inc ebx |
||
317 | stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0 |
||
318 | ret |
||
319 | |||
320 | ;рисование преобразованной текстуры |
||
321 | align 4 |
||
322 | draw_transf_texture: |
||
323 | cmp dword[buf_ogl],0 |
||
324 | je .endf |
||
325 | stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины |
||
326 | stdcall [glBegin],GL_TRIANGLES |
||
327 | |||
328 | stdcall [glTexCoord2f], dword[sel_pt+4*sizeof.point2d+point2d.tx], dword[sel_pt+4*sizeof.point2d+point2d.ty] ;5 |
||
329 | stdcall [glVertex3f], dword[sel_pt+7*sizeof.point2d+point2d.tx], dword[sel_pt+7*sizeof.point2d+point2d.ty], 0.1 ;8 |
||
330 | stdcall [glTexCoord2f], dword[sel_pt+point2d.tx], dword[sel_pt+point2d.ty] ;1 |
||
331 | stdcall [glVertex3f], dword[sel_pt+5*sizeof.point2d+point2d.tx], dword[sel_pt+5*sizeof.point2d+point2d.ty], 0.1 ;6 |
||
332 | stdcall [glTexCoord2f], dword[sel_pt+sizeof.point2d+point2d.tx], dword[sel_pt+sizeof.point2d+point2d.ty] ;2 |
||
333 | stdcall [glVertex3f], dword[sel_pt+6*sizeof.point2d+point2d.tx], dword[sel_pt+5*sizeof.point2d+point2d.ty], 0.1 ;7|6 |
||
334 | |||
335 | stdcall [glTexCoord2f], dword[sel_pt+4*sizeof.point2d+point2d.tx], dword[sel_pt+4*sizeof.point2d+point2d.ty] ;5 |
||
336 | stdcall [glVertex3f], dword[sel_pt+7*sizeof.point2d+point2d.tx], dword[sel_pt+7*sizeof.point2d+point2d.ty], 0.1 ;8 |
||
337 | stdcall [glTexCoord2f], dword[sel_pt+sizeof.point2d+point2d.tx], dword[sel_pt+sizeof.point2d+point2d.ty] ;2 |
||
338 | stdcall [glVertex3f], dword[sel_pt+6*sizeof.point2d+point2d.tx], dword[sel_pt+5*sizeof.point2d+point2d.ty], 0.1 ;7|6 |
||
339 | stdcall [glTexCoord2f], dword[sel_pt+2*sizeof.point2d+point2d.tx], dword[sel_pt+2*sizeof.point2d+point2d.ty] ;3 |
||
340 | stdcall [glVertex3f], dword[sel_pt+6*sizeof.point2d+point2d.tx], dword[sel_pt+6*sizeof.point2d+point2d.ty], 0.1 ;7 |
||
341 | |||
342 | stdcall [glTexCoord2f], dword[sel_pt+4*sizeof.point2d+point2d.tx], dword[sel_pt+4*sizeof.point2d+point2d.ty] ;5 |
||
343 | stdcall [glVertex3f], dword[sel_pt+7*sizeof.point2d+point2d.tx], dword[sel_pt+7*sizeof.point2d+point2d.ty], 0.1 ;8 |
||
344 | stdcall [glTexCoord2f], dword[sel_pt+2*sizeof.point2d+point2d.tx], dword[sel_pt+2*sizeof.point2d+point2d.ty] ;3 |
||
345 | stdcall [glVertex3f], dword[sel_pt+6*sizeof.point2d+point2d.tx], dword[sel_pt+6*sizeof.point2d+point2d.ty], 0.1 ;7 |
||
346 | stdcall [glTexCoord2f], dword[sel_pt+3*sizeof.point2d+point2d.tx], dword[sel_pt+3*sizeof.point2d+point2d.ty] ;4 |
||
347 | stdcall [glVertex3f], dword[sel_pt+5*sizeof.point2d+point2d.tx], dword[sel_pt+6*sizeof.point2d+point2d.ty], 0.1 ;6|7 |
||
348 | |||
349 | stdcall [glTexCoord2f], dword[sel_pt+4*sizeof.point2d+point2d.tx], dword[sel_pt+4*sizeof.point2d+point2d.ty] ;5 |
||
350 | stdcall [glVertex3f], dword[sel_pt+7*sizeof.point2d+point2d.tx], dword[sel_pt+7*sizeof.point2d+point2d.ty], 0.1 ;8 |
||
351 | stdcall [glTexCoord2f], dword[sel_pt+3*sizeof.point2d+point2d.tx], dword[sel_pt+3*sizeof.point2d+point2d.ty] ;4 |
||
352 | stdcall [glVertex3f], dword[sel_pt+5*sizeof.point2d+point2d.tx], dword[sel_pt+6*sizeof.point2d+point2d.ty], 0.1 ;6|7 |
||
353 | stdcall [glTexCoord2f], dword[sel_pt+point2d.tx], dword[sel_pt+point2d.ty] ;1 |
||
354 | stdcall [glVertex3f], dword[sel_pt+5*sizeof.point2d+point2d.tx], dword[sel_pt+5*sizeof.point2d+point2d.ty], 0.1 ;6 |
||
355 | |||
356 | stdcall [glEnd] |
||
357 | .endf: |
||
358 | ret |