Subversion Repositories Kolibri OS

Rev

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

Rev 6807 Rev 7105
Line 31... Line 31...
31
;> [_param]    = depends on _flags fields, see libimg.inc                                         ;;
31
;> [_param]    = depends on _flags fields, see libimg.inc                                         ;;
32
;;------------------------------------------------------------------------------------------------;;
32
;;------------------------------------------------------------------------------------------------;;
33
;< eax = 0 / pointer to converted image                                                           ;;
33
;< eax = 0 / pointer to converted image                                                           ;;
34
;< ecx = error code / undefined                                                                   ;;
34
;< ecx = error code / undefined                                                                   ;;
35
;;================================================================================================;;
35
;;================================================================================================;;
-
 
36
locals
-
 
37
        img     dd ?
-
 
38
        prev    dd ?
-
 
39
endl
36
        push    ebx esi edi 0 0
40
        push    ebx esi edi
-
 
41
        mov     [img], 0
-
 
42
        mov     [prev], 0
37
        mov     ebx, [_src]
43
        mov     ebx, [_src]
38
    @@:
44
    @@:
39
        mov     eax, [ebx + Image.Previous]
45
        mov     eax, [ebx + Image.Previous]
40
        test    eax, eax
46
        test    eax, eax
41
        jz      .loop
47
        jz      .loop
Line 43... Line 49...
43
        jmp     @b
49
        jmp     @b
44
  .loop:
50
  .loop:
45
        stdcall img.convert.layer, ebx, [_dst], [_dst_type], [_flags], [_param]
51
        stdcall img.convert.layer, ebx, [_dst], [_dst_type], [_flags], [_param]
46
        test    eax, eax
52
        test    eax, eax
47
        jz      .error
53
        jz      .error
48
        cmp     dword[esp + 4], 0
54
        cmp     [img], 0
49
        jnz     @f
55
        jnz     @f
50
        mov     [esp + 4], eax
56
        mov     [img], eax
51
    @@:
57
    @@:
52
        mov     ecx, [esp]
58
        mov     ecx, [prev]
53
        jecxz   @f
59
        jecxz   @f
54
        mov     [ecx + Image.Next], eax
60
        mov     [ecx + Image.Next], eax
-
 
61
        mov     [eax + Image.Previous], ecx
55
    @@:
62
    @@:
-
 
63
        mov     [prev], eax
56
	push	[ebx + Image.Flags]
64
        push    [ebx + Image.Flags]
57
	pop	[eax + Image.Flags]
65
        pop     [eax + Image.Flags]
58
	push	[ebx + Image.Delay]
66
        push    [ebx + Image.Delay]
59
	pop	[eax + Image.Delay]
67
        pop     [eax + Image.Delay]
60
        mov     [eax + Image.Previous], ecx
-
 
61
        mov     [esp], eax
-
 
62
        mov     ebx, [ebx + Image.Next]
68
        mov     ebx, [ebx + Image.Next]
63
        test    ebx, ebx
69
        test    ebx, ebx
64
        jnz     .loop
70
        jnz     .loop
65
  .quit:
-
 
66
        pop     eax eax edi esi ebx
71
        mov     eax, [img]
67
        ret
-
 
68
  .error:
72
  .error:
69
        pop     eax eax edi esi ebx
73
        pop     edi esi ebx
70
        ret
74
        ret
71
endp
75
endp
Line 72... Line 76...
72
 
76
 
Line 84... Line 88...
84
;;------------------------------------------------------------------------------------------------;;
88
;;------------------------------------------------------------------------------------------------;;
85
;< eax = 0 / pointer to converted image                                                           ;;
89
;< eax = 0 / pointer to converted image                                                           ;;
86
;< ecx = error code / undefined                                                                   ;;
90
;< ecx = error code / undefined                                                                   ;;
87
;;================================================================================================;;
91
;;================================================================================================;;
88
locals
92
locals
89
	width	rd 1
-
 
90
	height	rd 1
93
        fun     rd 1
91
endl
94
endl
92
        push    ebx esi edi
95
        push    ebx esi edi
Line 93... Line 96...
93
 
96
 
94
	mov	ebx, [_src]
97
        mov     ebx, [_src]
95
	mov	eax, 1
98
        mov     eax, [ebx + Image.Type]
96
	mov	ecx, [_dst_type]
99
        mov     esi, [img.convert.table + 4*eax]
97
	shl	eax, cl
100
  .next:
98
	mov	ecx, [ebx + Image.Type]
101
        lodsd
99
	test	eax, [img.types_table + 4*ecx]
102
        test    eax, eax
100
	jnz	@f
103
        jnz     @f
101
	mov	ecx, LIBIMG_ERROR_BIT_DEPTH
104
        mov     ecx, LIBIMG_ERROR_BIT_DEPTH
102
	jmp	.error
105
        jmp     .exit
-
 
106
    @@:
-
 
107
        cmp     eax, [_dst_type]
-
 
108
        lodsd
-
 
109
        jnz     .next
-
 
110
        mov     [fun], eax
103
    @@:
111
 
104
	mov	eax, [_dst]
112
        mov     eax, [_dst]
105
	test	eax, eax
113
        test    eax, eax
106
	jnz	@f
114
        jnz     @f
107
	stdcall	img.create, [ebx + Image.Width], [ebx + Image.Height], [_dst_type]
115
        stdcall img.create, [ebx + Image.Width], [ebx + Image.Height], [_dst_type]
108
	test	eax, eax
116
        test    eax, eax
109
	jz	.error
117
        jz      .exit
110
	mov	[_dst], eax
118
        mov     [_dst], eax
111
    @@:
119
    @@:
112
	mov	edi, [eax + Image.Data]
120
        mov     edi, [eax + Image.Data]
113
	mov	esi, [ebx + Image.Data]
121
        mov     esi, [ebx + Image.Data]
114
	mov	eax, [ebx + Image.Type]
122
        mov     eax, [ebx + Image.Type]
115
	cmp	eax, Image.bpp8i
-
 
116
	je	.bpp8i
123
        stdcall [fun], [_src], [_dst]
117
	cmp	eax, Image.bpp8g
-
 
118
	je	.bpp8g
-
 
119
	cmp	eax, Image.bpp24
-
 
120
	je	.bpp24
-
 
121
	cmp	eax, Image.bpp32
-
 
122
	je	.bpp32
-
 
123
	cmp	eax, Image.bpp15
124
        mov     eax, [_dst]
124
	je	.bpp15
125
  .exit:
125
	cmp	eax, Image.bpp16
126
        pop     edi esi ebx
126
	je	.bpp16
-
 
127
	cmp	eax, Image.bpp1
127
        ret
128
	je	.bpp1
-
 
129
	cmp	eax, Image.bpp8a
-
 
130
	je	.bpp8a
-
 
131
	mov	ecx, LIBIMG_ERROR_BIT_DEPTH
-
 
Line 132... Line -...
132
	jmp	.error
-
 
133
 
-
 
134
  .find_in_table_and_jump:
-
 
135
	mov	ecx, [_dst_type]
-
 
136
    @@:
-
 
137
	mov	eax, [edx]
-
 
138
	add	edx, 8
-
 
139
	cmp	eax, ecx
-
 
140
	jne	@b
-
 
141
	jmp	dword[edx - 4]
-
 
142
 
-
 
143
 
128
endp
144
  .bpp8i:
-
 
145
	mov	edx, img.convert.bpp8i.table
-
 
146
	jmp	.find_in_table_and_jump
129
 
147
  .bpp8i_to_bpp24:
130
proc img._.convert.bpp8i_to_bpp24 _src, _dst
Line 148... Line 131...
148
	mov	ecx, [ebx + Image.Width]
131
        mov     ecx, [ebx + Image.Width]
149
	imul	ecx, [ebx + Image.Height]
132
        imul    ecx, [ebx + Image.Height]
Line 163... Line 146...
163
	movzx	eax, byte[esi]
146
        movzx   eax, byte[esi]
164
	mov	eax, [ebx + eax*4]
147
        mov     eax, [ebx + eax*4]
165
	mov	[edi], ax
148
        mov     [edi], ax
166
	shr	eax, 16
149
        shr     eax, 16
167
	mov	[edi + 2], al
150
        mov     [edi + 2], al
168
	mov	eax, [_dst]
151
        ret
169
	jmp	.quit
152
endp
-
 
153
 
-
 
154
 
-
 
155
proc img._.convert.bpp8i_to_bpp32 _src, _dst
-
 
156
        mov     ecx, [ebx + Image.Width]
-
 
157
        imul    ecx, [ebx + Image.Height]
Line -... Line 158...
-
 
158
 
-
 
159
        mov     ebx, [ebx + Image.Palette]
-
 
160
    @@:
-
 
161
        movzx   eax, byte[esi]
-
 
162
        add     esi, 1
-
 
163
        mov     eax, [ebx + eax*4]
-
 
164
        mov     [edi], eax
-
 
165
        add     edi, 4
-
 
166
        dec     ecx
-
 
167
        jnz     @b
-
 
168
        ret
Line 170... Line -...
170
 
-
 
171
 
169
endp
172
 
-
 
173
  .bpp8g:
-
 
174
	mov	edx, img.convert.bpp8g.table
170
 
175
	jmp	.find_in_table_and_jump
171
 
176
  .bpp8g_to_bpp1:
172
proc img._.convert.bpp8g_to_bpp1 _src, _dst
177
	mov	eax, [_dst]
173
        mov     eax, [_dst]
178
	mov	eax, [eax + Image.Palette]
174
        mov     eax, [eax + Image.Palette]
Line 203... Line 199...
203
	mov	byte[edi], al
199
        mov     byte[edi], al
204
	add	edi, 1
200
        add     edi, 1
205
    @@:
201
    @@:
206
	dec	edx
202
        dec     edx
207
	jnz	.bpp8g_to_bpp1.line
203
        jnz     .bpp8g_to_bpp1.line
208
	mov	eax, [_dst]
-
 
209
	jmp	.quit
204
        ret
210
 
205
endp
211
  .bpp8g_to_bpp8g:
-
 
212
	mov	ecx, [ebx + Image.Width]
-
 
213
	imul	ecx, [ebx + Image.Height]
-
 
214
	rep	movsb
-
 
215
	mov	eax, [_dst]
-
 
216
	jmp	.quit
-
 
Line 217... Line 206...
217
 
206
 
218
  .bpp8g_to_bpp24:
207
proc img._.convert.bpp8g_to_bpp24 _src, _dst
219
	mov	ecx, [ebx + Image.Width]
208
        mov     ecx, [ebx + Image.Width]
220
	imul	ecx, [ebx + Image.Height]
209
        imul    ecx, [ebx + Image.Height]
221
    @@:
210
    @@:
222
	mov	al, byte[esi]
211
        mov     al, byte[esi]
Line 225... Line 214...
225
	mov	byte[edi + 2], al
214
        mov     byte[edi + 2], al
226
	add	esi, 1
215
        add     esi, 1
227
	add	edi, 3
216
        add     edi, 3
228
	sub	ecx, 1
217
        sub     ecx, 1
229
	jnz	@b
218
        jnz     @b
230
	mov	eax, [_dst]
219
        ret
231
	jmp	.quit
220
endp
-
 
221
 
Line 232... Line -...
232
 
-
 
233
  .bpp24:
222
 
234
	mov	edx, img.convert.bpp24.table
-
 
235
	jmp	.find_in_table_and_jump
-
 
236
  .bpp24_to_bpp24:
223
proc img._.convert.bpp24_to_bpp24 _src, _dst
237
	mov	ecx, [ebx + Image.Width]
224
        mov     ecx, [ebx + Image.Width]
238
	imul	ecx, [ebx + Image.Height]
225
        imul    ecx, [ebx + Image.Height]
239
	lea	ecx, [ecx*3]
226
        lea     ecx, [ecx*3]
240
	mov	edx, ecx
227
        mov     edx, ecx
241
	shr	ecx, 2
228
        shr     ecx, 2
242
	rep	movsd
229
        rep     movsd
243
	mov	ecx, edx
230
        mov     ecx, edx
244
	and	ecx, 3
231
        and     ecx, 3
245
	rep	movsb
232
        rep     movsb
246
	mov	eax, [_dst]
233
        ret
-
 
234
endp
-
 
235
 
247
	jmp	.quit
236
 
248
  .bpp24_to_bpp8g:
237
proc img._.convert.bpp24_to_bpp8g _src, _dst
249
	mov	ecx, [ebx + Image.Width]
238
        mov     ecx, [ebx + Image.Width]
250
	imul	ecx, [ebx + Image.Height]
239
        imul    ecx, [ebx + Image.Height]
251
    @@:
240
    @@:
252
	movzx	ebx, byte[esi + 0]
241
        movzx   ebx, byte[esi + 0]
Line 259... Line 248...
259
	div	bl
248
        div     bl
260
	mov	byte[edi], al
249
        mov     byte[edi], al
261
	add	edi, 1
250
        add     edi, 1
262
	sub	ecx, 1
251
        sub     ecx, 1
263
	jnz	@b
252
        jnz     @b
264
	mov	eax, [_dst]
253
        ret
265
	jmp	.quit
254
endp
-
 
255
 
-
 
256
 
266
  .bpp24_to_bpp32:
257
proc img._.convert.bpp24_to_bpp32 _src, _dst
267
	mov	ecx, [ebx + Image.Width]
258
        mov     ecx, [ebx + Image.Width]
268
	imul	ecx, [ebx + Image.Height]
259
        imul    ecx, [ebx + Image.Height]
269
    @@:
260
    @@:
270
        lodsw
261
        lodsw
271
        ror     eax, 16
262
        ror     eax, 16
272
        lodsb
263
        lodsb
273
        rol     eax, 16
264
        rol     eax, 16
274
        stosd
265
        stosd
275
        dec     ecx
266
        dec     ecx
276
        jnz     @b
267
        jnz     @b
277
	mov	eax, [_dst]
268
        ret
278
	jmp	.quit
269
endp
Line 279... Line -...
279
 
-
 
280
 
270
 
281
  .bpp32:
-
 
282
	mov	edx, img.convert.bpp32.table
-
 
283
	jmp	.find_in_table_and_jump
271
 
284
  .bpp32_to_bpp24:
272
proc img._.convert.bpp32_to_bpp24 _src, _dst
285
	mov	ecx, [ebx + Image.Width]
273
        mov     ecx, [ebx + Image.Width]
286
	imul	ecx, [ebx + Image.Height]
274
        imul    ecx, [ebx + Image.Height]
287
    @@:
275
    @@:
Line 291... Line 279...
291
	mov	[edi + 2], al
279
        mov     [edi + 2], al
292
	add	esi, 4
280
        add     esi, 4
293
	add	edi, 3
281
        add     edi, 3
294
	sub	ecx, 1
282
        sub     ecx, 1
295
	jnz	@b
283
        jnz     @b
296
	mov	eax, [_dst]
284
        ret
-
 
285
endp
-
 
286
 
-
 
287
 
-
 
288
proc img._.convert.bpp32_to_bpp32 _src, _dst
-
 
289
        mov     ecx, [ebx + Image.Width]
-
 
290
        imul    ecx, [ebx + Image.Height]
-
 
291
        rep     movsd
297
	jmp	.quit
292
        ret
-
 
293
endp
Line 298... Line -...
298
 
-
 
299
 
294
 
300
  .bpp15:
-
 
301
	mov	edx, img.convert.bpp15.table
-
 
302
	jmp	.find_in_table_and_jump
295
 
303
  .bpp15_to_bpp24:
296
proc img._.convert.bpp15_to_bpp24 _src, _dst
Line 304... Line 297...
304
	mov	ecx, [ebx + Image.Width]
297
        mov     ecx, [ebx + Image.Width]
305
	imul	ecx, [ebx + Image.Height]
298
        imul    ecx, [ebx + Image.Height]
Line 418... Line 411...
418
end repeat
411
end repeat
419
	sub	ecx, 4
412
        sub     ecx, 4
420
	jnb	.bpp15.amd.loop
413
        jnb     .bpp15.amd.loop
421
	jmp	.bpp15.tail
414
        jmp     .bpp15.tail
Line -... Line 415...
-
 
415
 
-
 
416
  .quit:
-
 
417
        ret
-
 
418
endp
Line 422... Line -...
422
 
-
 
423
 
419
 
424
  .bpp16:
-
 
425
	mov	edx, img.convert.bpp16.table
-
 
426
	jmp	.find_in_table_and_jump
420
 
427
  .bpp16_to_bpp24:
421
proc img._.convert.bpp16_to_bpp24 _src, _dst
428
	mov	ecx, [ebx + Image.Width]
422
        mov     ecx, [ebx + Image.Width]
429
	imul	ecx, [ebx + Image.Height]
423
        imul    ecx, [ebx + Image.Height]
430
  .bpp16.intel:
424
  .bpp16.intel:
Line 540... Line 534...
540
end repeat
534
end repeat
541
	sub	ecx, 4
535
        sub     ecx, 4
542
	jnb	.bpp16.amd.loop
536
        jnb     .bpp16.amd.loop
543
	jmp	.bpp16.tail
537
        jmp     .bpp16.tail
Line -... Line 538...
-
 
538
 
-
 
539
  .quit:
-
 
540
        ret
-
 
541
endp
Line 544... Line -...
544
 
-
 
545
 
542
 
-
 
543
 
546
  .bpp1:
544
proc img._.convert.bpp1_to_bpp24 _src, _dst
547
	mov	edx, img.convert.bpp1.table
545
locals
-
 
546
        width   rd 1
548
	jmp	.find_in_table_and_jump
547
        height  rd 1
549
  .bpp1_to_bpp24:
548
endl
550
	push	[ebx + Image.Width]
549
        push    [ebx + Image.Width]
551
	pop	[width]
550
        pop     [width]
552
	push	[ebx + Image.Height]
551
        push    [ebx + Image.Height]
Line 575... Line 574...
575
    @@:
574
    @@:
576
	sub	ah, 1
575
        sub     ah, 1
577
	jnz	.bpp1_to_bpp24.bit
576
        jnz     .bpp1_to_bpp24.bit
578
	jmp	.bpp1_to_bpp24.byte
577
        jmp     .bpp1_to_bpp24.byte
579
  .bpp1.done:
578
  .bpp1.done:
580
	mov	eax, [_dst]
579
        ret
581
	jmp	.quit
580
endp
Line 582... Line -...
582
 
-
 
583
 
581
 
584
  .bpp8a:
-
 
585
	mov	edx, img.convert.bpp8a.table
-
 
586
	jmp	.find_in_table_and_jump
582
 
587
  .bpp8a_to_bpp1:
583
proc img._.convert.bpp8a_to_bpp1 _src, _dst
588
	mov	eax, [_dst]
584
        mov     eax, [_dst]
589
	mov	eax, [eax + Image.Palette]
585
        mov     eax, [eax + Image.Palette]
590
	mov	dword[eax], 0x00000000
586
        mov     dword[eax], 0x00000000
Line 614... Line 610...
614
	mov	byte[edi], al
610
        mov     byte[edi], al
615
	add	edi, 1
611
        add     edi, 1
616
    @@:
612
    @@:
617
	dec	edx
613
        dec     edx
618
	jnz	.bpp8a_to_bpp1.line
614
        jnz     .bpp8a_to_bpp1.line
619
	mov	eax, [_dst]
615
        ret
620
	jmp	.quit
616
endp
Line -... Line 617...
-
 
617
 
621
 
618
 
622
  .bpp8a_to_bpp24:
619
proc img._.convert.bpp8a_to_bpp24 _src, _dst
623
	mov	ecx, [ebx + Image.Width]
620
        mov     ecx, [ebx + Image.Width]
624
	imul	ecx, [ebx + Image.Height]
621
        imul    ecx, [ebx + Image.Height]
625
    @@:
622
    @@:
626
	mov	al, byte[esi]
623
        mov     al, byte[esi]
Line 629... Line 626...
629
	mov	byte[edi + 2], al
626
        mov     byte[edi + 2], al
630
	add	esi, 2
627
        add     esi, 2
631
	add	edi, 3
628
        add     edi, 3
632
	sub	ecx, 1
629
        sub     ecx, 1
633
	jnz	@b
630
        jnz     @b
634
	mov	eax, [_dst]
-
 
635
	jmp	.quit
-
 
636
 
-
 
637
 
-
 
638
  .error:
-
 
639
	xor	eax, eax
-
 
640
  .quit:
-
 
641
        pop     edi esi ebx
-
 
642
	ret
631
        ret
643
endp
632
endp
Line 644... Line 633...
644
 
633
 
645
 
634
 
646
img.convert.bpp8i.table:
-
 
647
	dd Image.bpp24, img.convert.layer.bpp8i_to_bpp24
-
 
648
img.convert.bpp8g.table:
635
img.convert.bpp8i.table:
649
	dd Image.bpp24, img.convert.layer.bpp8g_to_bpp24
636
        dd Image.bpp24, img._.convert.bpp8i_to_bpp24
650
	dd Image.bpp8g, img.convert.layer.bpp8g_to_bpp8g
637
        dd Image.bpp32, img._.convert.bpp8i_to_bpp32
651
	dd Image.bpp1,  img.convert.layer.bpp8g_to_bpp1
638
        dd 0
652
img.convert.bpp24.table:
639
img.convert.bpp24.table:
653
	dd Image.bpp24, img.convert.layer.bpp24_to_bpp24
640
        dd Image.bpp24, img._.convert.bpp24_to_bpp24
-
 
641
        dd Image.bpp8g, img._.convert.bpp24_to_bpp8g
654
	dd Image.bpp8g, img.convert.layer.bpp24_to_bpp8g
642
        dd Image.bpp32, img._.convert.bpp24_to_bpp32
655
	dd Image.bpp32, img.convert.layer.bpp24_to_bpp32
643
        dd 0
-
 
644
img.convert.bpp32.table:
-
 
645
        dd Image.bpp24, img._.convert.bpp32_to_bpp24
656
img.convert.bpp32.table:
646
        dd Image.bpp32, img._.convert.bpp32_to_bpp32
657
	dd Image.bpp24, img.convert.layer.bpp32_to_bpp24
647
        dd 0
-
 
648
img.convert.bpp15.table:
658
img.convert.bpp15.table:
649
        dd Image.bpp24, img._.convert.bpp15_to_bpp24
659
	dd Image.bpp24, img.convert.layer.bpp15_to_bpp24
650
        dd 0
-
 
651
img.convert.bpp16.table:
660
img.convert.bpp16.table:
652
        dd Image.bpp24, img._.convert.bpp16_to_bpp24
661
	dd Image.bpp24, img.convert.layer.bpp16_to_bpp24
653
        dd 0
-
 
654
img.convert.bpp1.table:
-
 
655
        dd Image.bpp24, img._.convert.bpp1_to_bpp24
-
 
656
        dd 0
-
 
657
img.convert.bpp8g.table:
-
 
658
        dd Image.bpp24, img._.convert.bpp8g_to_bpp24
-
 
659
        dd Image.bpp1,  img._.convert.bpp8g_to_bpp1
-
 
660
        dd 0
-
 
661
img.convert.bpp2i.table:
-
 
662
        dd 0
662
img.convert.bpp1.table:
663
img.convert.bpp4i.table:
663
	dd Image.bpp24, img.convert.layer.bpp1_to_bpp24
664
        dd 0
-
 
665
img.convert.bpp8a.table:
-
 
666
        dd Image.bpp24, img._.convert.bpp8a_to_bpp24
-
 
667
        dd 0
-
 
668
 
-
 
669
img.convert.table:
-
 
670
        dd 0    ; no image type zero
-
 
671
        dd img.convert.bpp8i.table
-
 
672
        dd img.convert.bpp24.table
-
 
673
        dd img.convert.bpp32.table
-
 
674
        dd img.convert.bpp15.table
-
 
675
        dd img.convert.bpp16.table
-
 
676
        dd img.convert.bpp1.table
-
 
677
        dd img.convert.bpp8g.table
-
 
678
        dd img.convert.bpp2i.table