Subversion Repositories Kolibri OS

Rev

Rev 6327 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6327 Rev 6328
Line 1... Line -...
1
;**************************************************************************
-
 
2
;**********************DECODING BMP FILE(1,4,8,24 bits)*********************
-
 
3
;***************************************************************************
-
 
4
; BMPTOIMG -Convert BMP format TO IMG format
-
 
5
;***************************************************************************
-
 
6
bmptoimg:
-
 
7
 
-
 
8
    mov [bmp_load_area],esi
-
 
9
    mov [img_dest_area],edi
-
 
10
    xor eax,eax
-
 
11
    mov ax,word[esi+28]
-
 
12
    mov ebx,[esi+14]
-
 
13
    mov ecx,[esi+18]
-
 
14
    mov edx,[esi+22]
-
 
15
    mov [bmp_bits_per_pixel],ax
-
 
16
    mov [bmp_first_structure_size],ebx
-
 
17
    mov [Bmp_SizeY],edx
-
 
18
    mov [Bmp_SizeX],ecx
-
 
19
 
-
 
20
    xor eax,eax
-
 
21
    mov ax,[esi+28]
-
 
22
    mul  dword [esi+18]
-
 
23
    add  eax,31
-
 
24
    shr  eax,5
-
 
25
    mov  dword [bmptoimg_data_area_dwps],eax  ;dwps-doublewords per string
-
 
26
    shl  eax,2
-
 
27
    mov  dword [bmptoimg_data_area_bps],eax   ;bps-bytes per string
-
 
28
 
-
 
29
    cmp dword [esi+34],0
-
 
30
    jne  yespicsize  ;if picture size is defined
-
 
31
    mul dword [esi+22]
-
 
32
    mov dword [esi+34],eax
-
 
33
 
-
 
34
  yespicsize:
-
 
35
 
-
 
36
    mov  eax,[bmp_load_area]
-
 
37
    add  eax, [esi+10]	 ;how mach bytes to begin bitmap
-
 
38
    add  eax, [esi+34]	 ;size of bitmap in BMP file
-
 
39
    mov  dword [bmptoimg_data_area_eop],eax   ;eop-end of picture in file
-
 
40
    ;calculate bytes per string
-
 
41
    mov  eax, [esi+18]
-
 
42
    lea  eax,[eax+2*eax]   ;3x pixels in eax
-
 
43
    mov [bmp_bytes_per_string],eax
-
 
44
 
-
 
45
    mov esi,dword [bmptoimg_data_area_eop]
-
 
46
    sub esi,dword [bmptoimg_data_area_bps]
-
 
47
 
-
 
48
    mov ebp,[img_dest_area]
-
 
49
    mov edi,[img_dest_area]
-
 
50
    mov ebx,[bmp_load_area]
-
 
51
    add ebx, [bmp_first_structure_size]
-
 
52
    add ebx,14		;in ebx start of color table
-
 
53
 
-
 
54
 
-
 
55
    cmp [bmp_bits_per_pixel],24
-
 
56
    je	convert_to_24bpp
-
 
57
 
-
 
58
    cmp [bmp_bits_per_pixel],8
-
 
59
    je convert_to_8bpp
-
 
60
 
-
 
61
    cmp [bmp_bits_per_pixel],4
-
 
62
    je convert_to_4bpp
-
 
63
 
-
 
64
    cmp [bmp_bits_per_pixel],1
-
 
65
    je convert_to_1bpp
-
 
66
 
-
 
67
    jmp end_bmp
-
 
68
 
-
 
69
;--------------------------------------------------
-
 
70
;-----------Decoding 24 bit BMP file---------------
-
 
71
;--------------------------------------------------
-
 
72
convert_to_24bpp:
-
 
73
 
-
 
74
  mov ebx,[Bmp_SizeY]
-
 
75
  loop_convert_to_24bpp_y:
-
 
76
 
-
 
77
    mov edi,ebp
-
 
78
    mov  ecx,[bmptoimg_data_area_dwps]
-
 
79
 
-
 
80
     cld
-
 
81
     rep movsd
-
 
82
 
-
 
83
    sub  esi,[bmptoimg_data_area_bps]
-
 
84
    sub  esi,[bmptoimg_data_area_bps]
-
 
85
 
-
 
86
    add  ebp,eax
-
 
87
    dec ebx
-
 
88
    jnz loop_convert_to_24bpp_y
-
 
89
 
-
 
90
    jmp  end_bmp
-
 
91
;-----------------------------------------------------
-
 
92
;--------------Decoding 8 bits BMP file---------------
-
 
93
;-----------------------------------------------------
-
 
94
 convert_to_8bpp:
-
 
95
 
-
 
96
    mov ebp,[Bmp_SizeY]
-
 
97
    loop_convert_8bpp_y:
-
 
98
 
-
 
99
      mov ecx,[bmptoimg_data_area_bps]
-
 
100
      push edi
-
 
101
 
-
 
102
      loop_convert_8bpp_x:
-
 
103
 
-
 
104
	 xor eax,eax
-
 
105
	 mov al,byte [esi]
-
 
106
	 call converttable
-
 
107
	 inc esi
-
 
108
	 add edi,3
-
 
109
 
-
 
110
      dec ecx
-
 
111
      jnz loop_convert_8bpp_x
-
 
112
 
-
 
113
      pop edi
-
 
114
 
-
 
115
    add edi,[bmp_bytes_per_string]
-
 
116
    sub esi,[bmptoimg_data_area_bps]
-
 
117
    sub esi,[bmptoimg_data_area_bps]
-
 
118
 
-
 
119
    dec ebp
-
 
120
    jnz loop_convert_8bpp_y
-
 
121
 
-
 
122
    jmp end_bmp
-
 
123
;-----------------------------------------------------
-
 
124
;--------------Decoding 4 bits BMP file---------------
-
 
125
;-----------------------------------------------------
-
 
126
 convert_to_4bpp:
-
 
127
 
-
 
128
    mov ebp,[Bmp_SizeY]
-
 
129
    loop_convert_4bpp_y:
-
 
130
 
-
 
131
      mov ecx,[bmptoimg_data_area_bps]
-
 
132
      push edi
-
 
133
 
-
 
134
      loop_convert_4bpp_x:
-
 
135
 
-
 
136
	 mov [Bmp_save1],ecx
-
 
137
	 xor eax,eax
-
 
138
	 mov al,byte [esi]
-
 
139
	 xor ecx,ecx
-
 
140
	 mov cl,al
-
 
141
	 shr al,4   ;first pixel in byte
-
 
142
	 and cl,0xf ;second pixel in byte
-
 
143
	 call converttable   ;draw first pixel of byte
-
 
144
	 mov eax,ecx	       ;move second pixel to register al and draw
-
 
145
	 add edi,3
-
 
146
	 call converttable   ;draw second pixel of byte
-
 
147
	 add edi,3
-
 
148
	 mov ecx,[Bmp_save1]
-
 
149
	 inc esi
-
 
150
 
-
 
151
      dec ecx
-
 
152
      jnz loop_convert_4bpp_x
-
 
153
 
-
 
154
      pop edi
-
 
155
 
-
 
156
    add edi,[bmp_bytes_per_string]
-
 
157
    sub esi,[bmptoimg_data_area_bps]
-
 
158
    sub esi,[bmptoimg_data_area_bps]
-
 
159
 
-
 
160
    dec ebp
-
 
161
    jnz loop_convert_4bpp_y
-
 
162
 
-
 
163
    jmp end_bmp
-
 
164
;-----------------------------------------------------
-
 
165
;---------------Decoding 1 bit BMP file---------------
-
 
166
;-----------------------------------------------------
-
 
167
 convert_to_1bpp:
-
 
168
 
-
 
169
    mov ebp,[Bmp_SizeY]
-
 
170
    loop_convert_1bpp_y:
-
 
171
 
-
 
172
      mov ecx,[bmptoimg_data_area_bps]
-
 
173
      push edi
-
 
174
 
-
 
175
      loop_convert_1bpp_x:
-
 
176
 
-
 
177
	 xor eax,eax
-
 
178
	 mov al,byte [esi]
-
 
179
	 mov [Bmp_save1],ecx
-
 
180
	 mov  ecx,eax
-
 
181
	 mov  edx,7
-
 
182
	 nextbit:
-
 
183
	    xor  eax,eax
-
 
184
	    bt	 ecx,edx
-
 
185
	    jnc  noaddelem
-
 
186
	    inc  eax
-
 
187
	    noaddelem:
-
 
188
 
-
 
189
	    push edx
-
 
190
	    call converttable
-
 
191
	    pop  edx
-
 
192
 
-
 
193
	    add  edi,3
-
 
194
	    dec  edx
-
 
195
	 jns nextbit
-
 
196
	 mov ecx,[Bmp_save1]
-
 
197
	 inc esi
-
 
198
      dec ecx
-
 
199
      jnz loop_convert_1bpp_x
-
 
200
 
-
 
201
      pop edi
-
 
202
 
-
 
203
    add edi,[bmp_bytes_per_string]
-
 
204
    sub esi,[bmptoimg_data_area_bps]
-
 
205
    sub esi,[bmptoimg_data_area_bps]
-
 
206
 
-
 
207
    dec ebp
-
 
208
    jnz loop_convert_1bpp_y
-
 
209
 
-
 
210
    jmp end_bmp
-
 
211
;-----------------------------------------------------
-
 
212
  converttable:
-
 
213
    shl  eax,2
-
 
214
    add  eax,ebx
-
 
215
    mov  edx, dword [eax]
-
 
216
    mov [edi],edx
-
 
217
    ret
-
 
218
;-----------------------------------------------------
-
 
219
; DATA AREA
-
 
220
bmptoimg_data_area_bps	    dd 0
-
 
221
bmptoimg_data_area_dwps     dd 0
-
 
222
bmptoimg_data_area_eop	    dd 0
-
 
223
bmp_load_area		    dd 0
-
 
224
img_dest_area		    dd 0
-
 
225
bmp_bits_per_pixel	    dw 0
-
 
226
bmp_first_structure_size    dd 0
-
 
227
bmp_bytes_per_string	    dd 0
-
 
228
 
-
 
229
end_bmp:
-
 
230
 
-
 
231
ret
-
 
232
 
-
 
233
;***************************************************************************
1
;***************************************************************************
234
;*******************CODING BMP FILE(1,4,8,24 bits)**************************
2
;*******************CODING BMP FILE(1,4,8,24 bits)**************************
235
;***************************************************************************
3
;***************************************************************************
Line 236... Line 4...
236
 
4