Subversion Repositories Kolibri OS

Rev

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

Rev 783 Rev 999
Line 5... Line 5...
5
;;================================================================================================;;
5
;;================================================================================================;;
6
;;                                                                                                ;;
6
;;                                                                                                ;;
7
;; This file is part of Common development libraries (Libs-Dev).                                  ;;
7
;; This file is part of Common development libraries (Libs-Dev).                                  ;;
8
;;                                                                                                ;;
8
;;                                                                                                ;;
9
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
9
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
10
;; General Public License as published by the Free Software Foundation, either version 3 of the   ;;
10
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
11
;; License, or (at your option) any later version.                                                ;;
11
;; of the License, or (at your option) any later version.                                         ;;
12
;;                                                                                                ;;
12
;;                                                                                                ;;
13
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without  ;;
13
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without  ;;
14
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  ;;
14
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  ;;
15
;; General Public License for more details.                                                       ;;
15
;; Lesser General Public License for more details.                                                ;;
16
;;                                                                                                ;;
16
;;                                                                                                ;;
17
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
17
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev.  ;;
18
;; see .                                                            ;;
18
;; If not, see .                                                    ;;
19
;;                                                                                                ;;
19
;;                                                                                                ;;
20
;;================================================================================================;;
20
;;================================================================================================;;
21
;;                                                                                                ;;
21
;;                                                                                                ;;
22
;; References:                                                                                    ;;
22
;; References:                                                                                    ;;
23
;;   1. GIF LITE v3.0 (2004-2007)                                                                 ;;
23
;;   1. GIF LITE v3.0 (2004-2007)                                                                 ;;
Line 82... Line 82...
82
;< eax = 0 (error) or pointer to image                                                            ;;
82
;< eax = 0 (error) or pointer to image                                                            ;;
83
;;================================================================================================;;
83
;;================================================================================================;;
84
locals
84
locals
85
  img		     dd ?
85
  img		     dd ?
86
  global_color_table dd ?
86
  global_color_table dd ?
-
 
87
  global_color_table_size dd ?
87
endl
88
endl
Line 88... Line 89...
88
 
89
 
Line -... Line 90...
-
 
90
	push	ebx
89
	push	ebx
91
 
90
 
92
; img.is.gif is called by caller (img.decode)
91
	stdcall img.is.gif, [_data], [_length]
93
;	stdcall img.is.gif, [_data], [_length]
Line -... Line 94...
-
 
94
;	or	eax, eax
92
	or	eax, eax
95
;	jz	.error
93
	jz	.error
-
 
94
 
-
 
95
	mov	ebx, [_data]
-
 
96
;       cmp     [ebx + bmp.Header.info.Compression], bmp.BI_RGB
-
 
97
;       je      @f
-
 
Line 98... Line 96...
98
;       mov     eax, [ebx + bmp.Header.file.Size]
96
 
99
;       cmp     eax, [_length]
97
	mov	[global_color_table_size], 0
100
;       jne     .error
98
	mov	ebx, [_data]
101
 
99
 
102
	test	[ebx + gif.Header.lsd.Packed], gif.LSD.Packed.GlobalColorTableFlag
100
	test	[ebx + gif.Header.lsd.Packed], gif.LSD.Packed.GlobalColorTableFlag
103
	jz	@f
101
	jz	@f
104
	lea	eax, [ebx + sizeof.gif.Header]
102
	lea	eax, [ebx + sizeof.gif.Header]
105
	mov	[global_color_table], eax
-
 
106
	mov	cl, [ebx + gif.Header.lsd.Packed]
103
	mov	[global_color_table], eax
107
	and	cl, gif.LSD.Packed.SizeOfGlobalColorTableMask
104
	mov	cl, [ebx + gif.Header.lsd.Packed]
-
 
105
	and	cl, gif.LSD.Packed.SizeOfGlobalColorTableMask
108
	shr	cl, gif.LSD.Packed.SizeOfGlobalColorTableShift
106
	shr	cl, gif.LSD.Packed.SizeOfGlobalColorTableShift
109
	inc	cl
107
	mov	eax, 2
110
	mov	eax, 1
108
	shl	eax, cl
Line 111... Line 109...
111
	shl	eax, cl
109
	mov	[global_color_table_size], eax
Line 128... Line 126...
128
	stdcall img._.new
126
	stdcall img._.new
129
	or	eax, eax
127
	or	eax, eax
130
	jz	.error
128
	jz	.error
131
	mov	edx, [img]
129
	mov	edx, [img]
132
	mov	[eax + Image.Previous], edx
130
	mov	[eax + Image.Previous], edx
-
 
131
	test	edx, edx
-
 
132
	jz	@f
-
 
133
	mov	[edx + Image.Next], eax
-
 
134
@@:
133
	mov	[img], eax
135
	mov	[img], eax
134
	mov	edx, eax
136
	mov	edx, eax
-
 
137
	mov	[eax + Image.Type], Image.bpp8
Line 135... Line 138...
135
 
138
 
136
	mov	ecx, sizeof.gif.Image
-
 
137
	invoke	mem.alloc, ecx
139
	invoke	mem.alloc, sizeof.gif.Image
138
	or	eax, eax
140
	or	eax, eax
139
	jz	.error
141
	jz	.error
Line 140... Line 142...
140
	mov	[edx + Image.Extended], eax
142
	mov	[edx + Image.Extended], eax
Line 147... Line 149...
147
	movzx	ecx, [ebx + gif.ImageDescriptor.Height]
149
	movzx	ecx, [ebx + gif.ImageDescriptor.Height]
148
	stdcall img._.resize_data, [img], eax, ecx
150
	stdcall img._.resize_data, [img], eax, ecx
149
	or	eax, eax
151
	or	eax, eax
150
	jz	.error
152
	jz	.error
Line 151... Line 153...
151
 
153
 
152
	xor	ecx, ecx
154
	mov	esi, ebx
-
 
155
	mov	edi, [edx + Image.Extended]
-
 
156
	mov	ecx, sizeof.gif.ImageDescriptor
-
 
157
	rep	movsb
-
 
158
 
-
 
159
	mov	edi, [edx + Image.Palette]
-
 
160
	mov	esi, [global_color_table]
153
	mov	eax, [edx + Image.Extended]
161
	mov	ecx, [global_color_table_size]
154
	test	[ebx + gif.ImageDescriptor.Packed], gif.ID.Packed.LocalColorTableFlag
162
	test	[ebx + gif.ImageDescriptor.Packed], gif.ID.Packed.LocalColorTableFlag
-
 
163
	jz	@f
155
	jz	@f
164
	lea	esi, [ebx + sizeof.gif.ImageDescriptor]
156
	mov	cl, [ebx + gif.ImageDescriptor.Packed]
165
	mov	cl, [ebx + gif.ImageDescriptor.Packed]
157
	and	cl, gif.ID.Packed.SizeOfLocalColorTableMask
166
	and	cl, gif.ID.Packed.SizeOfLocalColorTableMask
158
	shr	cl, gif.ID.Packed.SizeOfLocalColorTableShift
-
 
159
	inc	cl
167
	shr	cl, gif.ID.Packed.SizeOfLocalColorTableShift
160
	mov	eax, 1
168
	mov	eax, 2
161
	shl	eax, cl
169
	shl	eax, cl
162
	lea	ecx, [eax * sizeof.gif.RgbTriplet]
170
	mov	ecx, eax
163
	lea	eax, [ecx + sizeof.gif.Image]
-
 
164
	invoke	mem.realloc, [edx + Image.Extended], eax
171
	lea	eax, [eax*3]
-
 
172
	add	ebx, eax
165
	or	eax, eax
173
@@:
166
	jz	.error
174
	lodsd
167
	mov	[edx + Image.Extended], eax
175
	dec	esi
168
    @@: mov	esi, ebx
-
 
169
	lea	edi, [eax + sizeof.gif.GraphicsControlExtension]
176
	bswap	eax
170
	add	ecx, sizeof.gif.ImageDescriptor
177
	shr	eax, 8
171
	rep	movsb
-
 
172
 
-
 
173
	mov	eax, [global_color_table]
-
 
174
	test	[ebx + gif.ImageDescriptor.Packed], gif.ID.Packed.LocalColorTableFlag
178
	stosd
175
	jz	@f
179
	loop	@b
176
	lea	eax, [ebx + sizeof.gif.ImageDescriptor]
-
 
177
    @@: mov	ebx, esi
180
	add	ebx, sizeof.gif.ImageDescriptor
Line 178... Line 181...
178
	stdcall ._.process_image, eax
181
	stdcall ._.process_image
179
 
182
 
180
  .decoded:
183
  .decoded:
181
	or	eax, eax
184
	or	eax, eax
Line 185... Line 188...
185
	
188
	
186
    @@: mov	eax, [img]
189
    @@: mov	eax, [img]
Line 187... Line 190...
187
	ret
190
	ret
-
 
191
 
-
 
192
  .error:
-
 
193
	mov	eax, [img]
-
 
194
	test	eax, eax
-
 
195
	jz	@f
188
 
196
	stdcall	img.destroy, eax
189
  .error:
197
@@:
190
	xor	eax, eax
198
	xor	eax, eax
191
	pop	ebx
199
	pop	ebx
Line 307... Line 315...
307
	pop	edx
315
	pop	edx
308
	ret
316
	ret
309
endp
317
endp
Line 310... Line 318...
310
 
318
 
311
;;================================================================================================;;
319
;;================================================================================================;;
312
proc img.decode.gif._.process_image _color_table ;////////////////////////////////////////////////;;
320
proc img.decode.gif._.process_image ;/////////////////////////////////////////////////////////////;;
313
;;------------------------------------------------------------------------------------------------;;
321
;;------------------------------------------------------------------------------------------------;;
314
;? --- TBD ---                                                                                    ;;
322
;? --- TBD ---                                                                                    ;;
315
;;------------------------------------------------------------------------------------------------;;
323
;;------------------------------------------------------------------------------------------------;;
316
;> ebx = raw image data                                                                           ;;
324
;> ebx = raw image data                                                                           ;;
Line 340... Line 348...
340
 
348
 
341
	mov	ecx, [edx + Image.Width]
349
	mov	ecx, [edx + Image.Width]
342
	mov	[width], ecx
350
	mov	[width], ecx
343
	mov	eax, [edx + Image.Height]
351
	mov	eax, [edx + Image.Height]
344
	imul	eax, ecx
-
 
345
;       lea     eax, [eax * 3]
-
 
346
	shl	eax, 2
352
	imul	eax, ecx
347
	mov	[img_end], eax
353
	mov	[img_end], eax
348
	inc	eax
354
	inc	eax
349
	mov	[row_end], eax
355
	mov	[row_end], eax
350
	and	[pass], 0
356
	and	[pass], 0
351
	mov	eax, [edx + Image.Extended]
357
	mov	eax, [edx + Image.Extended]
352
	test	[eax + gif.Image.info.Packed], gif.ID.Packed.InterleaceFlag
358
	test	[eax + gif.Image.info.Packed], gif.ID.Packed.InterleaceFlag
353
	jz	@f
-
 
354
;       lea     ecx, [ecx * 3]
-
 
355
	shl	ecx, 2
359
	jz	@f
Line 356... Line 360...
356
	mov	[row_end], ecx
360
	mov	[row_end], ecx
357
 
361
 
Line 500... Line 504...
500
	shl	ebx, 16
504
	shl	ebx, 16
501
	mov	bx, [esp]
505
	mov	bx, [esp]
Line 502... Line 506...
502
 
506
 
503
  .loop2:
507
  .loop2:
504
	pop	ax
-
 
505
 
-
 
506
	lea	esi, [eax * 3]
-
 
507
	add	esi, [_color_table]
-
 
508
 
-
 
509
	mov	esi, [esi]
508
	pop	ax
510
	bswap	esi
-
 
511
	shr	esi, 8
-
 
512
	mov	[edi], esi
-
 
Line 513... Line 509...
513
	add	edi, 4
509
	stosb
514
 
510
 
515
	cmp	edi, [row_end]
511
	cmp	edi, [row_end]
516
	jb	.norowend
-
 
517
	mov	eax, [width]
-
 
518
;       lea     eax, [eax * 3]
512
	jb	.norowend
519
	shl	eax, 2
513
	mov	eax, [width]
520
	push	eax
514
	push	eax
521
	sub	edi, eax
515
	sub	edi, eax
522
	add	eax, eax
516
	add	eax, eax