Rev 1079 | Rev 1118 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1079 | Rev 1102 | ||
---|---|---|---|
Line 70... | Line 70... | ||
70 | inc eax |
70 | inc eax |
71 | ret |
71 | ret |
72 | endp |
72 | endp |
Line 73... | Line 73... | ||
73 | 73 | ||
74 | ;;================================================================================================;; |
74 | ;;================================================================================================;; |
75 | proc img.decode.gif _data, _length ;//////////////////////////////////////////////////////////////;; |
75 | proc img.decode.gif _data, _length, _options ;////////////////////////////////////////////////////;; |
76 | ;;------------------------------------------------------------------------------------------------;; |
76 | ;;------------------------------------------------------------------------------------------------;; |
77 | ;? Decode data into image if it contains correctly formed raw data in GIF format ;; |
77 | ;? Decode data into image if it contains correctly formed raw data in GIF format ;; |
78 | ;;------------------------------------------------------------------------------------------------;; |
78 | ;;------------------------------------------------------------------------------------------------;; |
79 | ;> _data = raw data as read from file/stream ;; |
79 | ;> _data = raw data as read from file/stream ;; |
Line 84... | Line 84... | ||
84 | locals |
84 | locals |
85 | max_color dd ? |
85 | max_color dd ? |
86 | cur_color_table_size dd ? |
86 | cur_color_table_size dd ? |
87 | transparent_color dd ? |
87 | transparent_color dd ? |
88 | background_color dd ? |
88 | background_color dd ? |
- | 89 | options_bgr dd ? |
|
89 | prev_palette dd ? |
90 | prev_palette dd ? |
90 | aux_palette dd ? |
91 | aux_palette dd ? |
91 | img dd ? |
92 | img dd ? |
92 | prev_img_data dd ? |
93 | prev_img_data dd ? |
93 | aux_img_data dd ? |
94 | aux_img_data dd ? |
Line 108... | Line 109... | ||
108 | img.decode.gif.max_color equ max_color |
109 | img.decode.gif.max_color equ max_color |
109 | img.decode.gif._data equ _data |
110 | img.decode.gif._data equ _data |
110 | img.decode.gif.aux_img_data equ aux_img_data |
111 | img.decode.gif.aux_img_data equ aux_img_data |
111 | img.decode.gif.aux_img_type equ aux_img_type |
112 | img.decode.gif.aux_img_type equ aux_img_type |
112 | img.decode.gif.aux_palette equ aux_palette |
113 | img.decode.gif.aux_palette equ aux_palette |
- | 114 | img.decode.gif.options_bgr equ options_bgr |
|
113 | ; offset of _length parameter for child functions with ebp-based frame |
115 | ; offset of _length parameter for child functions with ebp-based frame |
114 | ; child saved ebp, return address, 3 saved registers, 14 local variables |
116 | ; child saved ebp, return address, 3 saved registers, 14 local variables |
115 | img.decode.gif._length_child equ _length + 4 + 4 + 4*3 + 4*14 |
117 | img.decode.gif._length_child equ _length + 4 + 4 + 4*3 + 4*14 |
116 | img.decode.gif.max_color_child equ ebp + 4 + 4 + 4*3 |
118 | img.decode.gif.max_color_child equ ebp + 4 + 4 + 4*3 |
117 | img.decode.gif.cur_color_table_size_child equ ebp + 4 + 4 + 4*3 + 4 |
119 | img.decode.gif.cur_color_table_size_child equ ebp + 4 + 4 + 4*3 + 4 |
Line 128... | Line 130... | ||
128 | ; when no previous image is available, use background fill with 1-entry palette |
130 | ; when no previous image is available, use background fill with 1-entry palette |
129 | inc eax |
131 | inc eax |
130 | mov [prev_num_colors], eax |
132 | mov [prev_num_colors], eax |
131 | lea eax, [background_color] |
133 | lea eax, [background_color] |
132 | mov [prev_palette], eax |
134 | mov [prev_palette], eax |
- | 135 | ; value for bgr color in transparent images |
|
- | 136 | mov edx, 0xFFFFFF ; white bgr if no value given |
|
- | 137 | mov ecx, [_options] |
|
- | 138 | jecxz @f |
|
133 | ; guard against incorrect gif files, which use Restore-To-Background disposal method, but do not define bgr color |
139 | cmp [ecx + ImageDecodeOptions.UsedSize], ImageDecodeOptions.BackgroundColor + 4 |
- | 140 | jb @f |
|
- | 141 | mov edx, [ecx + ImageDecodeOptions.BackgroundColor] |
|
- | 142 | @@: |
|
- | 143 | mov [options_bgr], edx |
|
134 | mov dword [eax], 0xFFFFFF |
144 | mov dword [eax], edx |
135 | ; guard against incorrect gif files without any color tables |
145 | ; guard against incorrect gif files without any color tables |
136 | ; "If no color table is available at |
146 | ; "If no color table is available at |
137 | ; all, the decoder is free to use a system color table or a table of its own. In |
147 | ; all, the decoder is free to use a system color table or a table of its own. In |
138 | ; that case, the decoder may use a color table with as many colors as its |
148 | ; that case, the decoder may use a color table with as many colors as its |
139 | ; hardware is able to support; it is recommended that such a table have black and |
149 | ; hardware is able to support; it is recommended that such a table have black and |
Line 788... | Line 798... | ||
788 | mov [transparent_color], ecx |
798 | mov [transparent_color], ecx |
789 | cmp edx, ebx |
799 | cmp edx, ebx |
790 | jnz .has_transparency |
800 | jnz .has_transparency |
791 | shl ecx, 2 |
801 | shl ecx, 2 |
792 | add ecx, [edx + Image.Palette] |
802 | add ecx, [edx + Image.Palette] |
793 | mov dword [background_color], 0xFFFFFF ; white background |
- | |
794 | mov dword [ecx], 0xFFFFFF |
- | |
795 | ; mov esi, [_data] |
- | |
796 | ; test [esi+gif.Header.lsd.Packed], gif.LSD.Packed.GlobalColorTableFlag |
- | |
797 | ; jz @f |
- | |
798 | ; movzx ecx, [esi+gif.Header.lsd.BackgroundColor] |
- | |
799 | ; push ecx |
803 | push eax |
800 | ; shl ecx, 2 |
804 | mov eax, [img.decode.gif.options_bgr] |
801 | ; add ecx, [edx + Image.Palette] |
805 | mov dword [background_color], eax |
802 | ; mov dword [ecx], 0xFFFFFF |
806 | mov dword [ecx], eax |
803 | ; pop ecx |
807 | pop eax |
804 | ; lea ecx, [ecx*3] |
- | |
805 | ; add esi, ecx |
- | |
806 | ; mov byte [esi+sizeof.gif.Header+0], 0xFF |
- | |
807 | ; mov byte [esi+sizeof.gif.Header+1], 0xFF |
- | |
808 | ; mov byte [esi+sizeof.gif.Header+2], 0xFF |
- | |
809 | @@: |
808 | @@: |
810 | call img.decode.gif._.is_logical_screen |
809 | call img.decode.gif._.is_logical_screen |
811 | jnz .has_transparency |
810 | jnz .has_transparency |
812 | ; image is not transparent, so keep it as is |
811 | ; image is not transparent, so keep it as is |
813 | retn |
812 | retn |