Subversion Repositories Kolibri OS

Rev

Rev 3036 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3036 Rev 3053
Line 16... Line 16...
16
;; If not, see .                                                    ;;
16
;; If not, see .                                                    ;;
17
;;                                                                                                ;;
17
;;                                                                                                ;;
18
;;================================================================================================;;
18
;;================================================================================================;;
Line 19... Line 19...
19
 
19
 
20
;;================================================================================================;;
20
;;================================================================================================;;
21
proc img.scale _src, _crop_x, _crop_y, _crop_width, _crop_height, _dst, _scale_type, _scale_alg, _param1, _param2 ;;
21
proc img.scale _src, _crop_x, _crop_y, _crop_width, _crop_height, _dst, _scale, _inter, _param1, _param2 ;;
22
;;------------------------------------------------------------------------------------------------;;
22
;;------------------------------------------------------------------------------------------------;;
23
;? scale _image                                                                                   ;;
23
;? scale _image                                                                                   ;;
24
;;------------------------------------------------------------------------------------------------;;
24
;;------------------------------------------------------------------------------------------------;;
25
;> [_src]         = pointer to source image                                                       ;;
25
;> [_src]         = pointer to source image                                                       ;;
26
;> [_crop_x]      = left coord of cropping rect                                                   ;;
26
;> [_crop_x]      = left coord of cropping rect                                                   ;;
27
;> [_crop_y]      = top coord of cropping rect                                                    ;;
27
;> [_crop_y]      = top coord of cropping rect                                                    ;;
28
;> [_crop_width]  = width of cropping rect                                                        ;;
28
;> [_crop_width]  = width of cropping rect                                                        ;;
29
;> [_crop_height] = height of cropping rect                                                       ;;
29
;> [_crop_height] = height of cropping rect                                                       ;;
30
;> [_dst]         = pointer to resulting image / 0                                                ;;
30
;> [_dst]         = pointer to resulting image / 0                                                ;;
31
;> [_scale_type]  = how to change width and height. see libimg.inc                                ;;
31
;> [_scale]       = how to change width and height. see libimg.inc                                ;;
32
;> [_scale_alg]   = algorithm to use. see libimg.inc                                              ;;
32
;> [_inter]       = interpolation algorithm                                                       ;;
33
;> [_param1]      = the first argument passed to _scale_alg algorithm                             ;;
33
;> [_param1]      = see libimg.inc                                                                ;;
34
;> [_param2]      = the second argument passed to _scale_alg algorithm                            ;;
34
;> [_param2]      = see libimg.inc                                                                ;;
35
;;------------------------------------------------------------------------------------------------;;
35
;;------------------------------------------------------------------------------------------------;;
36
;< eax = 0 / pointer to scaled image                                                              ;;
36
;< eax = 0 / pointer to scaled image                                                              ;;
37
;< ecx = error code / undefined                                                                   ;;
37
;< ecx = error code / undefined                                                                   ;;
38
;;================================================================================================;;
38
;;================================================================================================;;
Line 43... Line 43...
43
 
43
 
44
	src_width_pixels	rd 1
44
	src_width_pixels	rd 1
45
	src_width_bytes		rd 1
45
	src_width_bytes		rd 1
Line 46... Line 46...
46
	src_height_pixels	rd 1
46
	src_height_pixels	rd 1
47
 
47
 
48
	scl_width_pixels	rd 1
48
	dst_width_pixels	rd 1
49
	scl_width_pixels_inv	rd 1
49
	dst_width_pixels_inv	rd 1
50
	scl_height_pixels	rd 1
50
	dst_height_pixels	rd 1
51
	scl_height_pixels_inv	rd 1
51
	dst_height_pixels_inv	rd 1
Line 52... Line 52...
52
	scl_width_bytes		rd 1
52
	dst_width_bytes		rd 1
53
	bytes_per_pixel		rd 1
53
	bytes_per_pixel		rd 1
54
 
54
 
Line 87... Line 87...
87
    @@:
87
    @@:
88
	cmp	eax, Image.bpp24
88
	cmp	eax, Image.bpp24
89
	jne	@f
89
	jne	@f
90
	mov	[bytes_per_pixel], 3
90
	mov	[bytes_per_pixel], 3
91
	lea	ecx, [ecx*3]
91
	lea	ecx, [ecx*3]
92
	lea	edx, [ecx*3]
92
	lea	edx, [edx*3]
93
	jmp	.lab1
93
	jmp	.lab1
94
    @@:
94
    @@:
95
	cmp	eax, Image.bpp8g
95
	cmp	eax, Image.bpp8g
96
	jne	@f
96
	jne	@f
97
	mov	[bytes_per_pixel], 1
97
	mov	[bytes_per_pixel], 1
Line 102... Line 102...
102
  .lab1:
102
  .lab1:
103
	mov	[src_width_bytes], ecx
103
	mov	[src_width_bytes], ecx
104
	add	[src_data], edx
104
	add	[src_data], edx
Line 105... Line 105...
105
 
105
 
106
 
106
 
-
 
107
	mov	eax, [_scale]
-
 
108
	cmp	eax, LIBIMG_SCALE_INTEGER
-
 
109
	je	.scale_type.integer
-
 
110
	cmp	eax, LIBIMG_SCALE_TILE
-
 
111
	je	.scale_type.tile
-
 
112
	cmp	eax, LIBIMG_SCALE_FIT_RECT
-
 
113
	je	.scale_type.fit_rect
-
 
114
	cmp	eax, LIBIMG_SCALE_FIT_WIDTH
-
 
115
	je	.scale_type.fit_width
-
 
116
	cmp	eax, LIBIMG_SCALE_FIT_HEIGHT
-
 
117
	je	.scale_type.fit_height
-
 
118
	cmp	eax, LIBIMG_SCALE_FIT_MAX
-
 
119
	je	.scale_type.fit_max
-
 
120
	cmp	eax, LIBIMG_SCALE_STRETCH
-
 
121
	je	.scale_type.stretch
-
 
122
	mov	ecx, LIBIMG_ERROR_SCALE
-
 
123
	jmp	.error
107
	mov	eax, [_scale_alg]
124
 
-
 
125
  .scale_type.integer:
-
 
126
	jmp	.integer
-
 
127
  .scale_type.tile:
-
 
128
	jmp	.tile
-
 
129
  .scale_type.fit_rect:
-
 
130
	mov	eax, [_param1]
-
 
131
	shl	eax, 16
-
 
132
	add	eax, 0x00008000
-
 
133
	xor	edx, edx
-
 
134
	div	[src_width_pixels]
-
 
135
	mov	ebx, eax
-
 
136
	mov	eax, [_param2]
-
 
137
	shl	eax, 16
-
 
138
	add	eax, 0x00008000
-
 
139
	xor	edx, edx
-
 
140
	div	[src_height_pixels]
-
 
141
	mov	ecx, eax
-
 
142
	cmp	ebx, ecx
-
 
143
	jb	@f
-
 
144
	mov	ebx, ecx
-
 
145
    @@:
-
 
146
	jmp	.scale_type.fit_common
-
 
147
  .scale_type.fit_max:
-
 
148
	mov	eax, [_param1]
-
 
149
	shl	eax, 16
-
 
150
	add	eax, 0x00008000
-
 
151
	xor	edx, edx
-
 
152
	div	[src_width_pixels]
-
 
153
	mov	ebx, eax
-
 
154
	mov	eax, [_param2]
-
 
155
	shl	eax, 16
-
 
156
	add	eax, 0x00008000
-
 
157
	xor	edx, edx
-
 
158
	div	[src_height_pixels]
-
 
159
	mov	ecx, eax
-
 
160
	cmp	ebx, ecx
-
 
161
	ja	@f
-
 
162
	mov	ebx, ecx
-
 
163
    @@:
-
 
164
	jmp	.scale_type.fit_common
-
 
165
  .scale_type.fit_width:
-
 
166
	mov	eax, [_param1]
-
 
167
	shl	eax, 16
-
 
168
	add	eax, 0x00008000
-
 
169
	xor	edx, edx
-
 
170
	div	[src_width_pixels]
-
 
171
	mov	ebx, eax
-
 
172
	jmp	.scale_type.fit_common
-
 
173
  .scale_type.fit_height:
-
 
174
	mov	eax, [_param2]
-
 
175
	shl	eax, 16
-
 
176
	add	eax, 0x00008000
-
 
177
	xor	edx, edx
-
 
178
	div	[src_height_pixels]
-
 
179
	mov	ebx, eax
-
 
180
	jmp	.scale_type.fit_common
-
 
181
  .scale_type.fit_common:
-
 
182
	mov	eax, [src_width_pixels]
-
 
183
	mul	ebx
-
 
184
	shr	eax, 16
-
 
185
	mov	[dst_width_pixels], eax
-
 
186
	imul	eax, [bytes_per_pixel]
-
 
187
	mov	[dst_width_bytes], eax
-
 
188
	mov	eax, [src_height_pixels]
-
 
189
	mul	ebx
-
 
190
	shr	eax, 16
-
 
191
	mov	[dst_height_pixels], eax
-
 
192
	jmp	.define_inter
-
 
193
  .scale_type.stretch:
-
 
194
	mov	eax, [_param1]
-
 
195
	mov	[dst_width_pixels], eax
-
 
196
	imul	eax, [bytes_per_pixel]
-
 
197
	mov	[dst_width_bytes], eax
-
 
198
	mov	ecx, [_param2]
-
 
199
	mov	[dst_height_pixels], ecx
-
 
200
	jmp	.define_inter
108
	cmp	eax, LIBIMG_SCALE_ALG_INTEGER
201
  .define_inter:
109
	je	.integer
202
	mov	eax, [_inter]
110
	cmp	eax, LIBIMG_SCALE_ALG_BILINEAR
203
	cmp	eax, LIBIMG_INTER_BILINEAR
111
	je	.bilinear
204
	je	.bilinear
Line -... Line 205...
-
 
205
	mov	ecx, LIBIMG_ERROR_INTER
112
	mov	ecx, LIBIMG_ERROR_SCALE_ALG
206
	jmp	.error
113
	jmp	.error
207
 
114
 
208
 
115
  .integer:
209
  .integer:
116
	mov	eax, [_param1]
210
	mov	eax, [_param1]
117
	mov	ecx, [_crop_width]
211
	mov	ecx, [_crop_width]
118
	imul	ecx, eax
212
	imul	ecx, eax
119
	mov	[scl_width_pixels], ecx
213
	mov	[dst_width_pixels], ecx
Line 120... Line 214...
120
	mov	edx, [_crop_height]
214
	mov	edx, [_crop_height]
121
	imul	edx, eax
215
	imul	edx, eax
122
	mov	[scl_height_pixels], edx
216
	mov	[dst_height_pixels], edx
123
 
217
 
124
	mov	eax, [_dst]
218
	mov	eax, [_dst]
125
	test	eax, eax
219
	test	eax, eax
126
	jnz	@f
220
	jnz	@f
127
	stdcall	img.create, [scl_width_pixels], [scl_height_pixels], [src_type]
221
	stdcall	img.create, [dst_width_pixels], [dst_height_pixels], [src_type]
128
	test	eax, eax
222
	test	eax, eax
Line 142... Line 236...
142
	je	.integer.bpp32
236
	je	.integer.bpp32
143
	mov	ecx, LIBIMG_ERROR_BIT_DEPTH
237
	mov	ecx, LIBIMG_ERROR_BIT_DEPTH
144
	jmp	.error
238
	jmp	.error
Line 145... Line 239...
145
 
239
 
146
  .integer.bpp8g:
240
  .integer.bpp8g:
147
	push	[scl_width_pixels]
241
	push	[dst_width_pixels]
148
	pop	[scl_width_bytes]
242
	pop	[dst_width_bytes]
149
	mov	ecx, [_param1]
243
	mov	ecx, [_param1]
150
;	cmp	ecx, 1
244
;	cmp	ecx, 1
151
;	je	.error
245
;	je	.error
152
  .integer.bpp8g.common:
246
  .integer.bpp8g.common:
Line 161... Line 255...
161
	rep	stosb
255
	rep	stosb
162
	dec	ebx
256
	dec	ebx
163
	jnz	@b
257
	jnz	@b
164
	push	esi
258
	push	esi
165
	mov	esi, edi
259
	mov	esi, edi
166
	sub	esi, [scl_width_bytes]
260
	sub	esi, [dst_width_bytes]
167
	mov	ecx, edx
261
	mov	ecx, edx
168
	dec	ecx
262
	dec	ecx
169
	imul	ecx, [scl_width_bytes]
263
	imul	ecx, [dst_width_bytes]
170
	mov	eax, ecx
264
	mov	eax, ecx
171
	shr	ecx, 2
265
	shr	ecx, 2
172
	and	eax, 0x00000003
266
	and	eax, 0x00000003
173
	rep	movsd
267
	rep	movsd
174
	mov	ecx, eax
268
	mov	ecx, eax
Line 182... Line 276...
182
	jnz	.integer.bpp8g.common.line
276
	jnz	.integer.bpp8g.common.line
183
	mov	eax, [_dst]
277
	mov	eax, [_dst]
184
	jmp	.quit
278
	jmp	.quit
Line 185... Line 279...
185
 
279
 
186
  .integer.bpp24:
280
  .integer.bpp24:
187
	mov	eax, [scl_width_pixels]
281
	mov	eax, [dst_width_pixels]
188
	lea	eax, [eax*3]
282
	lea	eax, [eax*3]
189
	mov	[scl_width_bytes], eax
283
	mov	[dst_width_bytes], eax
190
	mov	ecx, [_param1]
284
	mov	ecx, [_param1]
191
;	cmp	ecx, 1
285
;	cmp	ecx, 1
192
;	je	.error
286
;	je	.error
193
  .integer.bpp24.common:
287
  .integer.bpp24.common:
Line 209... Line 303...
209
	pop	esi
303
	pop	esi
210
	dec	ebx
304
	dec	ebx
211
	jnz	@b
305
	jnz	@b
212
	push	esi
306
	push	esi
213
	mov	esi, edi
307
	mov	esi, edi
214
	sub	esi, [scl_width_bytes]
308
	sub	esi, [dst_width_bytes]
215
	mov	ecx, edx
309
	mov	ecx, edx
216
	dec	ecx
310
	dec	ecx
217
	imul	ecx, [scl_width_bytes]
311
	imul	ecx, [dst_width_bytes]
218
	mov	eax, ecx
312
	mov	eax, ecx
219
	shr	ecx, 2
313
	shr	ecx, 2
220
	and	eax, 0x00000003
314
	and	eax, 0x00000003
221
	rep	movsd
315
	rep	movsd
222
	mov	ecx, eax
316
	mov	ecx, eax
Line 231... Line 325...
231
	jnz	.integer.bpp24.common.line
325
	jnz	.integer.bpp24.common.line
232
	mov	eax, [_dst]
326
	mov	eax, [_dst]
233
	jmp	.quit
327
	jmp	.quit
Line 234... Line 328...
234
 
328
 
235
  .integer.bpp32:
329
  .integer.bpp32:
236
	mov	eax, [scl_width_pixels]
330
	mov	eax, [dst_width_pixels]
237
	shl	eax, 2
331
	shl	eax, 2
238
	mov	[scl_width_bytes], eax
332
	mov	[dst_width_bytes], eax
239
	mov	ecx, [_param1]
333
	mov	ecx, [_param1]
240
;	cmp	ecx, 1
334
;	cmp	ecx, 1
241
;	je	.error
335
;	je	.error
242
  .integer.bpp32.common:
336
  .integer.bpp32.common:
Line 251... Line 345...
251
	rep	stosd
345
	rep	stosd
252
	dec	ebx
346
	dec	ebx
253
	jnz	@b
347
	jnz	@b
254
	push	esi
348
	push	esi
255
	mov	esi, edi
349
	mov	esi, edi
256
	sub	esi, [scl_width_bytes]
350
	sub	esi, [dst_width_bytes]
257
	mov	ecx, edx
351
	mov	ecx, edx
258
	dec	ecx
352
	dec	ecx
259
	imul	ecx, [scl_width_bytes]
353
	imul	ecx, [dst_width_bytes]
260
	shr	ecx, 2
354
	shr	ecx, 2
261
	rep	movsd
355
	rep	movsd
262
	pop	esi
356
	pop	esi
263
	mov	eax, [src_width_pixels]
357
	mov	eax, [src_width_pixels]
264
	sub	eax, [_crop_width]
358
	sub	eax, [_crop_width]
Line 269... Line 363...
269
	jnz	.integer.bpp32.common.line
363
	jnz	.integer.bpp32.common.line
270
	mov	eax, [_dst]
364
	mov	eax, [_dst]
271
	jmp	.quit
365
	jmp	.quit
Line 272... Line 366...
272
 
366
 
273
 
-
 
274
  .bilinear:
-
 
275
	mov	eax, [_scale_type]
-
 
276
	cmp	eax, LIBIMG_SCALE_TYPE_FIT_RECT
-
 
277
	je	.bilinear.fit_rect
-
 
278
	cmp	eax, LIBIMG_SCALE_TYPE_FIT_WIDTH
-
 
279
	je	.bilinear.fit_width
-
 
280
	cmp	eax, LIBIMG_SCALE_TYPE_FIT_HEIGHT
-
 
281
	je	.bilinear.fit_height
-
 
282
	cmp	eax, LIBIMG_SCALE_TYPE_FIT_MAX
-
 
283
	je	.bilinear.fit_max
-
 
284
	cmp	eax, LIBIMG_SCALE_TYPE_STRETCH
-
 
285
	je	.bilinear.stretch
-
 
286
	mov	ecx, LIBIMG_ERROR_SCALE_TYPE
-
 
287
	jmp	.error
367
 
288
  .bilinear.fit_rect:
-
 
289
	mov	eax, [_param1]
-
 
290
	shl	eax, 16
368
  .tile:
291
	add	eax, 0x00008000
369
	mov	eax, [_param1]
292
	xor	edx, edx
370
	mov	[dst_width_pixels], eax
293
	div	[src_width_pixels]
371
	imul	eax, [bytes_per_pixel]
294
	mov	ebx, eax
372
	mov	[dst_width_bytes], eax
-
 
373
	mov	eax, [_param2]
295
	mov	eax, [_param2]
374
	mov	[dst_height_pixels], eax
296
	shl	eax, 16
375
 
297
	add	eax, 0x00008000
-
 
298
	xor	edx, edx
376
	mov	eax, [_dst]
-
 
377
	test	eax, eax
299
	div	[src_height_pixels]
378
	jnz	@f
300
	mov	ecx, eax
379
	stdcall	img.create, [dst_width_pixels], [dst_height_pixels], [src_type]
301
	cmp	ebx, ecx
380
	test	eax, eax
302
	jb	@f
381
	jz	.error
303
	mov	ebx, ecx
-
 
304
    @@:
-
 
305
	jmp	.bilinear.fit_common
382
	mov	[_dst], eax
306
  .bilinear.fit_max:
-
 
307
	mov	eax, [_param1]
-
 
308
	shl	eax, 16
383
    @@:
309
	add	eax, 0x00008000
-
 
-
 
384
	mov	edi, [eax + Image.Data]
310
	xor	edx, edx
385
	mov	[dst_data], edi
311
	div	[src_width_pixels]
386
 
312
	mov	ebx, eax
-
 
313
	mov	eax, [_param2]
-
 
314
	shl	eax, 16
-
 
315
	add	eax, 0x00008000
387
	mov	esi, [src_data]
316
	xor	edx, edx
-
 
317
	div	[src_height_pixels]
-
 
318
	mov	ecx, eax
388
	mov	eax, [_crop_height]
319
	cmp	ebx, ecx
389
	cmp	eax, [dst_height_pixels]
320
	ja	@f
390
	jna	@f
321
	mov	ebx, ecx
-
 
322
    @@:
-
 
323
	jmp	.bilinear.fit_common
-
 
324
  .bilinear.fit_width:
391
	mov	eax, [dst_height_pixels]
325
	mov	eax, [_param1]
-
 
326
	shl	eax, 16
-
 
327
	add	eax, 0x00008000
-
 
328
	xor	edx, edx
-
 
329
	div	[src_width_pixels]
-
 
330
	mov	ebx, eax
-
 
331
	jmp	.bilinear.fit_common
392
    @@:
332
  .bilinear.fit_height:
-
 
333
	mov	eax, [_param2]
-
 
334
	shl	eax, 16
-
 
335
	add	eax, 0x00008000
393
	push	eax
336
	xor	edx, edx
394
	mov	ecx, [_crop_width]
337
	div	[src_height_pixels]
-
 
338
	mov	ebx, eax
-
 
339
	jmp	.bilinear.fit_common
395
	cmp	ecx, [dst_width_pixels]
340
  .bilinear.fit_common:
396
	jna	@f
341
	mov	eax, [src_width_pixels]
-
 
342
	mul	ebx
-
 
343
	shr	eax, 16
397
	mov	ecx, [dst_width_pixels]
344
	mov	[scl_width_pixels], eax
-
 
345
	imul	eax, [bytes_per_pixel]
-
 
346
	mov	[scl_width_bytes], eax
-
 
347
	mov	eax, [src_height_pixels]
398
    @@:
348
	mul	ebx
-
 
349
	shr	eax, 16
-
 
350
	mov	[scl_height_pixels], eax
399
	imul	ecx, [bytes_per_pixel]
351
	jmp	.bilinear.common
-
 
352
  .bilinear.stretch:
-
 
353
	mov	eax, [_param1]
-
 
354
	mov	[scl_width_pixels], eax
-
 
355
	imul	eax, [bytes_per_pixel]
400
	mov	edx, ecx
356
	mov	[scl_width_bytes], eax
-
 
357
	mov	ecx, [_param2]
401
    @@:
Line -... Line 402...
-
 
402
	mov	ecx, edx
-
 
403
	rep	movsb
-
 
404
 
-
 
405
	push	esi
-
 
406
	mov	esi, edi
-
 
407
	sub	esi, edx
-
 
408
	mov	ecx, [dst_width_bytes]
-
 
409
	sub	ecx, edx
-
 
410
	rep	movsb
-
 
411
	pop	esi
-
 
412
 
-
 
413
	mov	ecx, [src_width_bytes]
-
 
414
	sub	ecx, edx
-
 
415
	add	esi, ecx
-
 
416
	dec	eax
-
 
417
	jnz	@b
-
 
418
 
-
 
419
	pop	eax
-
 
420
	mov	esi, [dst_data]
-
 
421
	mov	ecx, [dst_height_pixels]
-
 
422
	sub	ecx, eax
-
 
423
	imul	ecx, [dst_width_bytes]
-
 
424
	rep	movsb
-
 
425
 
-
 
426
	mov	eax, [_dst]
358
	mov	[scl_height_pixels], ecx
427
	jmp	.quit
359
	jmp	.bilinear.common
428
 
360
 
429
 
361
  .bilinear.common:
430
  .bilinear:
362
	mov	eax, [_dst]
431
	mov	eax, [_dst]
363
	test	eax, eax
432
	test	eax, eax
364
	jnz	@f
433
	jnz	@f
365
	stdcall	img.create, [scl_width_pixels], [scl_height_pixels], [src_type]
434
	stdcall	img.create, [dst_width_pixels], [dst_height_pixels], [src_type]
366
	test	eax, eax
435
	test	eax, eax
367
	jz	.error
436
	jz	.error
Line 377... Line 446...
377
	pop	[crop_height_pixels_m1]
446
	pop	[crop_height_pixels_m1]
378
	sub	[crop_height_pixels_m1], 1
447
	sub	[crop_height_pixels_m1], 1
Line 379... Line 448...
379
 
448
 
380
	mov	eax, 0xffffffff
449
	mov	eax, 0xffffffff
381
	xor	edx, edx
450
	xor	edx, edx
382
	div	[scl_width_pixels]
451
	div	[dst_width_pixels]
383
	mov	[scl_width_pixels_inv], eax
452
	mov	[dst_width_pixels_inv], eax
384
	mov	eax, 0xffffffff
453
	mov	eax, 0xffffffff
385
	xor	edx, edx
454
	xor	edx, edx
386
	div	[scl_height_pixels]
455
	div	[dst_height_pixels]
Line 387... Line 456...
387
	mov	[scl_height_pixels_inv], eax
456
	mov	[dst_height_pixels_inv], eax
388
 
457
 
389
	mov	eax, [src_type]
458
	mov	eax, [src_type]
390
	cmp	eax, Image.bpp8g
459
	cmp	eax, Image.bpp8g
Line 403... Line 472...
403
  .bilinear.bpp8g.line:
472
  .bilinear.bpp8g.line:
404
	mov	esi, [src_data]
473
	mov	esi, [src_data]
405
	mov	[dst_x], 0
474
	mov	[dst_x], 0
406
	imul	eax, [crop_height_pixels_m1]
475
	imul	eax, [crop_height_pixels_m1]
407
	xor	edx, edx
476
	xor	edx, edx
408
	div	[scl_height_pixels]
477
	div	[dst_height_pixels]
409
	mov	[rem_y], edx
478
	mov	[rem_y], edx
410
	imul	eax, [src_width_bytes]
479
	imul	eax, [src_width_bytes]
411
	add	esi, eax
480
	add	esi, eax
412
	mov	[src_base], esi
481
	mov	[src_base], esi
413
	mov	eax, 0	; mov eax, [dst_x]
482
	mov	eax, 0	; mov eax, [dst_x]
Line 415... Line 484...
415
  .bilinear.bpp8g.pixel:
484
  .bilinear.bpp8g.pixel:
416
	mov	esi, [src_base]
485
	mov	esi, [src_base]
Line 417... Line 486...
417
 
486
 
418
	imul	eax, [crop_width_pixels_m1]
487
	imul	eax, [crop_width_pixels_m1]
419
	xor	edx, edx
488
	xor	edx, edx
420
	div	[scl_width_pixels]
489
	div	[dst_width_pixels]
Line 421... Line 490...
421
	add	esi, eax
490
	add	esi, eax
422
 
491
 
423
	mov	ax, word[esi]
492
	mov	ax, word[esi]
Line 430... Line 499...
430
	and	ebx, 0x000000ff
499
	and	ebx, 0x000000ff
Line 431... Line 500...
431
 
500
 
432
	imul	edx, esi
501
	imul	edx, esi
433
	imul	ecx, esi
502
	imul	ecx, esi
434
	neg	esi
503
	neg	esi
435
	add	esi, [scl_width_pixels]
504
	add	esi, [dst_width_pixels]
436
	imul	eax, esi
505
	imul	eax, esi
437
	imul	ebx, esi
506
	imul	ebx, esi
438
	add	eax, edx
507
	add	eax, edx
439
	add	ebx, ecx
508
	add	ebx, ecx
440
	mov	esi, [scl_width_pixels_inv]
509
	mov	esi, [dst_width_pixels_inv]
441
	mul	esi
510
	mul	esi
442
	mov	ecx, edx
511
	mov	ecx, edx
443
	mov	eax, ebx
512
	mov	eax, ebx
444
	mul	esi
513
	mul	esi
Line 445... Line 514...
445
	mov	eax, edx
514
	mov	eax, edx
446
 
515
 
447
	mov	edx, [rem_y]
516
	mov	edx, [rem_y]
448
	imul	eax, edx
517
	imul	eax, edx
449
	neg	edx
518
	neg	edx
450
	add	edx, [scl_height_pixels]
519
	add	edx, [dst_height_pixels]
451
	imul	ecx, edx
520
	imul	ecx, edx
452
	add	eax, ecx
521
	add	eax, ecx
453
	mul	[scl_height_pixels_inv]
522
	mul	[dst_height_pixels_inv]
Line 454... Line 523...
454
	mov	byte[edi], dl
523
	mov	byte[edi], dl
455
	add	edi, 1
524
	add	edi, 1
456
 
525
 
457
	add	[dst_x], 1
526
	add	[dst_x], 1
Line 458... Line 527...
458
	mov	eax, [dst_x]
527
	mov	eax, [dst_x]
459
	cmp	eax, [scl_width_pixels]
528
	cmp	eax, [dst_width_pixels]
460
	jne	.bilinear.bpp8g.pixel
529
	jne	.bilinear.bpp8g.pixel
461
 
530
 
Line 462... Line 531...
462
	add	[dst_y], 1
531
	add	[dst_y], 1
463
	mov	eax, [dst_y]
532
	mov	eax, [dst_y]
Line 475... Line 544...
475
  .bilinear.bpp24.line:
544
  .bilinear.bpp24.line:
476
	mov	esi, [src_data]
545
	mov	esi, [src_data]
477
	mov	[dst_x], 0
546
	mov	[dst_x], 0
478
	imul	eax, [crop_height_pixels_m1]
547
	imul	eax, [crop_height_pixels_m1]
479
	xor	edx, edx
548
	xor	edx, edx
480
	div	[scl_height_pixels]
549
	div	[dst_height_pixels]
481
	mov	[rem_y], edx
550
	mov	[rem_y], edx
482
	imul	eax, [src_width_bytes]
551
	imul	eax, [src_width_bytes]
483
	add	esi, eax
552
	add	esi, eax
484
	mov	[src_base], esi
553
	mov	[src_base], esi
485
	mov	eax, 0	; mov eax, [dst_x]
554
	mov	eax, 0	; mov eax, [dst_x]
Line 487... Line 556...
487
  .bilinear.bpp24.pixel:
556
  .bilinear.bpp24.pixel:
488
	mov	esi, [src_base]
557
	mov	esi, [src_base]
Line 489... Line 558...
489
 
558
 
490
	imul	eax, [crop_width_pixels_m1]
559
	imul	eax, [crop_width_pixels_m1]
491
	xor	edx, edx
560
	xor	edx, edx
492
	div	[scl_width_pixels]
561
	div	[dst_width_pixels]
493
	lea	eax, [eax*3]
562
	lea	eax, [eax*3]
Line 494... Line 563...
494
	add	esi, eax
563
	add	esi, eax
495
 
564
 
Line 512... Line 581...
512
	and	eax, 0x000000ff
581
	and	eax, 0x000000ff
Line 513... Line 582...
513
 
582
 
514
	imul	edx, esi
583
	imul	edx, esi
515
	imul	ecx, esi
584
	imul	ecx, esi
516
	neg	esi
585
	neg	esi
517
	add	esi, [scl_width_pixels]
586
	add	esi, [dst_width_pixels]
518
	imul	eax, esi
587
	imul	eax, esi
519
	imul	ebx, esi
588
	imul	ebx, esi
520
	add	eax, edx
589
	add	eax, edx
521
	add	ebx, ecx
590
	add	ebx, ecx
522
	mov	esi, [scl_width_pixels_inv]
591
	mov	esi, [dst_width_pixels_inv]
523
	mul	esi
592
	mul	esi
524
	mov	ecx, edx
593
	mov	ecx, edx
525
	mov	eax, ebx
594
	mov	eax, ebx
526
	mul	esi
595
	mul	esi
Line 527... Line 596...
527
	mov	eax, edx
596
	mov	eax, edx
528
 
597
 
529
	mov	edx, [rem_y]
598
	mov	edx, [rem_y]
530
	imul	eax, edx
599
	imul	eax, edx
531
	neg	edx
600
	neg	edx
532
	add	edx, [scl_height_pixels]
601
	add	edx, [dst_height_pixels]
533
	imul	ecx, edx
602
	imul	ecx, edx
534
	add	eax, ecx
603
	add	eax, ecx
535
	mul	[scl_height_pixels_inv]
604
	mul	[dst_height_pixels_inv]
536
	mov	byte[edi], dl
605
	mov	byte[edi], dl
Line 537... Line 606...
537
	add	edi, 1
606
	add	edi, 1
538
end repeat
607
end repeat
539
 
608
 
540
	add	[dst_x], 1
609
	add	[dst_x], 1
Line 541... Line 610...
541
	mov	eax, [dst_x]
610
	mov	eax, [dst_x]
542
	cmp	eax, [scl_width_pixels]
611
	cmp	eax, [dst_width_pixels]
543
	jne	.bilinear.bpp24.pixel
612
	jne	.bilinear.bpp24.pixel
544
 
613
 
Line 545... Line 614...
545
	add	[dst_y], 1
614
	add	[dst_y], 1
546
	mov	eax, [dst_y]
615
	mov	eax, [dst_y]
Line 557... Line 626...
557
  .bilinear.bpp32.line:
626
  .bilinear.bpp32.line:
558
	mov	esi, [src_data]
627
	mov	esi, [src_data]
559
	mov	[dst_x], 0
628
	mov	[dst_x], 0
560
	imul	eax, [crop_height_pixels_m1]
629
	imul	eax, [crop_height_pixels_m1]
561
	xor	edx, edx
630
	xor	edx, edx
562
	div	[scl_height_pixels]
631
	div	[dst_height_pixels]
563
	mov	[rem_y], edx
632
	mov	[rem_y], edx
564
	imul	eax, [src_width_bytes]
633
	imul	eax, [src_width_bytes]
565
	add	esi, eax
634
	add	esi, eax
566
	mov	[src_base], esi
635
	mov	[src_base], esi
567
	mov	eax, 0	; mov eax, [dst_x]
636
	mov	eax, 0	; mov eax, [dst_x]
Line 569... Line 638...
569
  .bilinear.bpp32.pixel:
638
  .bilinear.bpp32.pixel:
570
	mov	esi, [src_base]
639
	mov	esi, [src_base]
Line 571... Line 640...
571
 
640
 
572
	imul	eax, [crop_width_pixels_m1]
641
	imul	eax, [crop_width_pixels_m1]
573
	xor	edx, edx
642
	xor	edx, edx
574
	div	[scl_width_pixels]
643
	div	[dst_width_pixels]
575
	shl	eax, 2
644
	shl	eax, 2
Line 576... Line 645...
576
	add	esi, eax
645
	add	esi, eax
577
 
646
 
Line 594... Line 663...
594
	and	eax, 0x000000ff
663
	and	eax, 0x000000ff
Line 595... Line 664...
595
 
664
 
596
	imul	edx, esi
665
	imul	edx, esi
597
	imul	ecx, esi
666
	imul	ecx, esi
598
	neg	esi
667
	neg	esi
599
	add	esi, [scl_width_pixels]
668
	add	esi, [dst_width_pixels]
600
	imul	eax, esi
669
	imul	eax, esi
601
	imul	ebx, esi
670
	imul	ebx, esi
602
	add	eax, edx
671
	add	eax, edx
603
	add	ebx, ecx
672
	add	ebx, ecx
604
	mov	esi, [scl_width_pixels_inv]
673
	mov	esi, [dst_width_pixels_inv]
605
	mul	esi
674
	mul	esi
606
	mov	ecx, edx
675
	mov	ecx, edx
607
	mov	eax, ebx
676
	mov	eax, ebx
608
	mul	esi
677
	mul	esi
Line 609... Line 678...
609
	mov	eax, edx
678
	mov	eax, edx
610
 
679
 
611
	mov	edx, [rem_y]
680
	mov	edx, [rem_y]
612
	imul	eax, edx
681
	imul	eax, edx
613
	neg	edx
682
	neg	edx
614
	add	edx, [scl_height_pixels]
683
	add	edx, [dst_height_pixels]
615
	imul	ecx, edx
684
	imul	ecx, edx
616
	add	eax, ecx
685
	add	eax, ecx
617
	mul	[scl_height_pixels_inv]
686
	mul	[dst_height_pixels_inv]
618
	mov	byte[edi], dl
687
	mov	byte[edi], dl
Line 619... Line 688...
619
	add	edi, 1
688
	add	edi, 1
620
end repeat
689
end repeat
621
 
690
 
622
	add	[dst_x], 1
691
	add	[dst_x], 1
Line 623... Line 692...
623
	mov	eax, [dst_x]
692
	mov	eax, [dst_x]
624
	cmp	eax, [scl_width_pixels]
693
	cmp	eax, [dst_width_pixels]
625
	jne	.bilinear.bpp32.pixel
694
	jne	.bilinear.bpp32.pixel
626
 
695
 
Line 627... Line 696...
627
	add	[dst_y], 1
696
	add	[dst_y], 1
628
	mov	eax, [dst_y]
697
	mov	eax, [dst_y]