Subversion Repositories Kolibri OS

Rev

Rev 2188 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2000 mario79 1
;---------------------------------------------------------------------
2
; ÓÑÒÀÍÎÂÈÒÜ ÔÎÍ
3
background:
4
	cmp	[soi],0
5
	je	.end
2163 mario79 6
 
2000 mario79 7
	cmp	[bgrmode],dword 2
2163 mario79 8
	ja	.stretch_crop
9
 
2000 mario79 10
	mov	ecx,[img_width]	;	øèðèíà
11
	test	ecx,ecx
12
	jz	.end
13
	mov	edx,[img_high]	; âûñîòà 
14
	test	edx,edx
15
	jz	.end
16
	mcall	15,1	; set size
17
 
18
	mov	esi,ecx
19
	imul	esi,edx
20
	lea	esi,[esi*3]
21
	mov	ecx,[soi]
22
 
23
	xor	edx,edx
24
 
25
	cmp	[img_resolution],24
26
	je	@f
2163 mario79 27
 
2000 mario79 28
	push	dword image_file
29
	call	[convert_Conv_24b]
2163 mario79 30
 
2000 mario79 31
	mov	ecx,[raw_pointer_2]
2163 mario79 32
	add	ecx,44
33
	mcall	15,5		;15,5 set data
34
	mcall	68,13,[raw_pointer_2]
2000 mario79 35
	jmp	.set_mode
36
@@:
2163 mario79 37
	mcall	15,5		; 15,5 set data
2000 mario79 38
.set_mode:
2163 mario79 39
	mcall	15,4,[bgrmode]	; 15,4 set mode
40
	dec	ebx		; 15,3 redraw background
2000 mario79 41
	mcall
42
.end:
43
	ret
2163 mario79 44
;---------------------------------------------------------------------
45
.stretch_crop:
2236 mario79 46
	cmp	[bgrmode],dword 3
47
	jne	.stretch_inscribe
2163 mario79 48
	xor	eax,eax
49
	mov	[stretch_start_coordinates],eax
50
 
51
	mcall	14
52
 
53
	mov	ebx,eax
54
	and	eax,0xffff
55
	inc	eax
56
	mov	[screen_high],eax
57
	shr	ebx,16
58
	inc	ebx
59
	mov	[screen_width],ebx
60
 
61
	xchg	eax,ebx
62
	call	calculate_relation
63
	mov	[screen_relation],eax
64
 
65
	mov	eax,[img_width]
66
	mov	ebx,[img_high]
67
	call	calculate_relation
68
	mov	[picture_relation],eax
69
 
70
	cmp	eax,[screen_relation]
71
	jb	@f
72
; Y = Yimg
73
; X = Yimg*Xscreen/Yscreen
74
	mov	eax,[img_high]
75
	mov	[stretch_img_high],eax
76
	mov	eax,[img_high]
77
	imul	eax,dword [screen_width]
78
	mov	ebx,[screen_high]
79
	call	integer_division
80
	mov	[stretch_img_width],eax
81
	jmp	.continue
82
@@:
83
; X = Ximg
84
; Y = Ximg*Yscreen/Xscreen
85
	mov	eax,[img_width]
86
	mov	[stretch_img_width],eax
87
	mov	eax,[img_width]
88
	imul	eax,dword [screen_high]
89
	mov	ebx,[screen_width]
90
	call	integer_division
91
	mov	[stretch_img_high],eax
92
.continue:
2188 mario79 93
	mov	eax,[Stretch_Crop_Corner]
94
	mov	ebx,eax
95
	shr	eax,16
96
	shl	eax,2
97
	mov	eax,[eax+call_to_calculate_stretch_start_coordinates_Y]
98
	call	eax
99
	and	ebx,0xffff
100
	shl	ebx,2
101
	mov	ebx,[ebx+call_to_calculate_stretch_start_coordinates_X]
102
	call	ebx
103
 
2163 mario79 104
	mov	ebx,[screen_width]
105
	shl	ebx,16
106
	add	ebx,[screen_high]
107
 
108
	mov	eax,[stretch_img_width]
109
	shl	eax,16
110
	add	eax,[stretch_img_high]
111
 
112
	push	dword eax			; eax - crop size
113
	push	dword 0				; edi - background color
114
	push	dword 1				; esi - filtering
115
	push	dword 0				; edx - scaling mode
116
	push	dword [stretch_start_coordinates]	; ecx - start_coordinates
117
	push	ebx				; ebx - new_size
118
	push	dword image_file		; eax -  convert data table
119
 
120
	call	[Scaling_Start]
121
	call	background_1
122
	ret
2236 mario79 123
;---------------------------------------------------------------------
124
.stretch_inscribe:
125
	xor	eax,eax
126
	mov	[stretch_start_coordinates],eax
127
 
128
	mcall	14
129
 
130
	mov	ebx,eax
131
	and	eax,0xffff
132
	inc	eax
133
	mov	[screen_high],eax
134
	shr	ebx,16
135
	inc	ebx
136
	mov	[screen_width],ebx
2163 mario79 137
 
2236 mario79 138
	xchg	eax,ebx
139
	call	calculate_relation
140
	mov	[screen_relation],eax
141
 
142
	mov	eax,[img_width]
143
	mov	ebx,[img_high]
144
	call	calculate_relation
145
	mov	[picture_relation],eax
146
 
147
	cmp	eax,[screen_relation]
148
	ja	@f
149
; Y = Yimg
150
; X = Yimg*Xscreen/Yscreen
151
	mov	eax,[screen_high]	;[img_high]
152
	mov	[stretch_img_high],eax
153
	mov	eax,[screen_high]	;[img_high]
154
	imul	eax,dword [img_width]	;[screen_width]
155
	mov	ebx,[img_high]		;[screen_high]
156
	call	integer_division
157
	mov	[stretch_img_width],eax
158
	jmp	.continue_1
159
@@:
160
; X = Ximg
161
; Y = Ximg*Yscreen/Xscreen
162
	mov	eax,[screen_width]	;[img_width]
163
	mov	[stretch_img_width],eax
164
	mov	eax,[screen_width]	;[img_width]
165
	imul	eax,dword [img_high]	;[screen_high]
166
	mov	ebx,[img_width]		;[screen_width]
167
	call	integer_division
168
	mov	[stretch_img_high],eax
169
.continue_1:
170
;	mov	ebx,[screen_width]
171
;	shl	ebx,16
172
;	add	ebx,[screen_high]
173
 
174
	mov	ebx,[stretch_img_width]
175
	shl	ebx,16
176
	add	ebx,[stretch_img_high]
177
 
178
 
179
	push	dword 0				; eax - crop size
180
	push	dword 0				; edi - background color
181
	push	dword 1				; esi - filtering
182
	push	dword 0				; edx - scaling mode
183
	push	dword [stretch_start_coordinates]	; ecx - start_coordinates
184
	push	ebx				; ebx - new_size
185
	push	dword image_file		; eax -  convert data table
186
 
187
	call	[Scaling_Start]
188
 
189
	mov	eax,[raw_pointer_2]
190
	mov	[crop_raw_pointer],eax
191
	mov	[crop_raw_pointer_2],eax
192
 
193
	mov	eax,[raw_pointer_2]
194
	mov	eax,[eax+12]		;overall depth of the pixel
195
	cmp	al,24
196
	je	@f
197
 
198
	push	dword crop_image_file
199
	call	[convert_Conv_24b]
200
 
201
	mov	ecx,[raw_pointer_2]
202
	mcall	68,13
203
@@:
204
	mov	ecx,[screen_width]
205
	imul	ecx,[screen_high]
206
	lea	ecx,[ecx*3]
207
	add	ecx,44
208
 
209
;	mcall	68,20,,[crop_raw_pointer_2]
210
;	mov	[crop_raw_pointer_2],eax
211
	mov	eax,[crop_raw_pointer_2]
212
	mov	[crop_raw_pointer],eax
213
 
214
	mcall	68,12
215
	mov	[crop_raw_pointer_2],eax
216
 
217
; fill of color
218
	sub	ecx,44
219
	mov	edi,eax
220
	add	edi,44
221
	mov	eax,0xaaaaaa
222
	cld
223
@@:
224
	stosb
225
	ror	eax,8
226
	stosb
227
	ror	eax,8
228
	stosb
229
	rol	eax,16
230
	sub	ecx,2
231
	loop	@b
232
 
233
; copy of data
234
	mov	eax,[screen_width]
235
	sub	eax,[stretch_img_width]
236
	mov	ebx,eax
237
	lea	eax,[eax*3]
238
	shr	ebx,1
239
	lea	ebx,[ebx*3]
240
 
241
	mov	edi,[screen_high]
242
	sub	edi,[stretch_img_high]
243
	shr	edi,1
244
	imul	edi,[screen_width]
245
	lea	edi,[edi*3]
246
	add	edi,[crop_raw_pointer_2]
247
	add	edi,44
248
	add	edi,ebx
249
 
250
	mov	esi,[crop_raw_pointer]
251
	add	esi,44
252
 
253
	mov	ebx,[stretch_img_width]
254
	lea	ebx,[ebx*3]
255
 
256
	mov	ecx,[stretch_img_high]
257
@@:
258
	push	ecx
259
	mov	ecx,ebx
260
	rep	movsb
261
	pop	ecx
262
	add	edi,eax
263
	loop	@b
264
 
265
; header
266
	mov	esi,[crop_raw_pointer]
267
	mov	edi,[crop_raw_pointer_2]
268
	mov	ecx,44/4
269
	rep	stosd
270
 
271
	mcall	68,13,[crop_raw_pointer]
272
;set the background
273
	mov	eax,[crop_raw_pointer_2]
274
	mov	ebx,[screen_width]
275
	mov	[eax+4],ebx
276
	mov	ebx,[screen_high]
277
	mov	[eax+8],ebx
278
 
279
	mov	ecx,[screen_width]	; øèðèíà
280
	test	ecx,ecx
281
	jz	@f
282
	mov	edx,[screen_high]	; âûñîòà 
283
	test	edx,edx
284
	jz	@f
285
	mcall	15,1	; set size
286
 
287
	mov	esi,ecx
288
	imul	esi,edx
289
	lea	esi,[esi*3]
290
 
291
	xor	edx,edx
292
	mov	ecx,[crop_raw_pointer_2]
293
	add	ecx,44
294
	mcall	15,5		;15,5 set data
295
	xor	ecx,ecx
296
	inc	ecx
297
	mcall	15,4		; 15,4 set mode
298
	dec	ebx		; 15,3 redraw background
299
	mcall
300
@@:
301
	mcall	68,13,[crop_raw_pointer_2]
302
	ret
2163 mario79 303
;---------------------------------------------------------------------
2188 mario79 304
call_to_calculate_stretch_start_coordinates_X:
305
	dd	calculate_stretch_start_coordinates_XL
306
	dd	calculate_stretch_start_coordinates_XC
307
	dd	calculate_stretch_start_coordinates_XR
308
;---------------------------------------------------------------------
309
call_to_calculate_stretch_start_coordinates_Y:
310
	dd	calculate_stretch_start_coordinates_YU
311
	dd	calculate_stretch_start_coordinates_YC
312
	dd	calculate_stretch_start_coordinates_YD
313
;---------------------------------------------------------------------
314
calculate_stretch_start_coordinates_XC:
315
	xor	ecx,ecx
316
.1:
317
	mov	eax,[img_width]
318
	sub	eax,[stretch_img_width]
319
	test	ecx,ecx
320
	jnz	@f
321
	shr	eax,1
322
@@:
323
	mov	[stretch_start_coordinates.x],ax
324
calculate_stretch_start_coordinates_XL:
325
	ret
326
;---------------------------------------------------------------------
327
calculate_stretch_start_coordinates_XR:
328
	xor	ecx,ecx
329
	inc	ecx
330
	jmp	calculate_stretch_start_coordinates_XC.1
331
;---------------------------------------------------------------------
332
calculate_stretch_start_coordinates_YC:
333
	xor	ecx,ecx
334
.1:
335
	mov	eax,[img_high]
336
	sub	eax,[stretch_img_high]
337
	test	ecx,ecx
338
	jnz	@f
339
	shr	eax,1
340
@@:
341
	mov	[stretch_start_coordinates.y],ax
342
calculate_stretch_start_coordinates_YU:
343
	ret
344
;---------------------------------------------------------------------
345
calculate_stretch_start_coordinates_YD:
346
	xor	ecx,ecx
347
	inc	ecx
348
	jmp	calculate_stretch_start_coordinates_YC.1
349
;---------------------------------------------------------------------
2163 mario79 350
background_1:
351
	mov	ecx,[screen_width]	;[crop_img_width]	; øèðèíà
352
	test	ecx,ecx
353
	jz	.end
354
	mov	edx,[screen_high]	;[crop_img_high]	; âûñîòà 
355
	test	edx,edx
356
	jz	.end
357
	mcall	15,1	; set size
2236 mario79 358
.1:
2163 mario79 359
	mov	esi,ecx
360
	imul	esi,edx
361
	lea	esi,[esi*3]
362
	mov	ecx,[raw_pointer_2]	;[soi]
363
	mov	eax,[ecx+28]
364
	add	ecx,eax
365
 
366
	xor	edx,edx
367
 
368
	mov	eax,[raw_pointer_2]
369
	mov	eax,[eax+12]		;overall depth of the pixel
370
	cmp	al,24
371
	je	@f
372
 
373
	mov	eax,[raw_pointer_2]
374
	mov	[crop_raw_pointer],eax
375
 
376
	push	dword crop_image_file
377
	call	[convert_Conv_24b]
378
 
379
	mov	ecx,[crop_raw_pointer_2]
380
	add	ecx,44
381
	mcall	15,5		;15,5 set data
382
	mcall	68,13,[crop_raw_pointer_2]
383
	jmp	.set_mode
384
@@:
385
	mcall	15,5		; 15,5 set data
386
.set_mode:
387
	xor	ecx,ecx
388
	inc	ecx
389
;	mov	ecx,[bgrmode]
390
	mcall	15,4		; 15,4 set mode
391
	dec	ebx		; 15,3 redraw background
392
	mcall
393
.end:
394
	mov	ecx,[raw_pointer_2]
395
	mcall	68,13
396
	ret
2000 mario79 397
;---------------------------------------------------------------------