Subversion Repositories Kolibri OS

Rev

Rev 1957 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1951 mario79 1
;*****************************************************************************
2
; Rotate RAW image plugin - for zSea image viewer
3
; Copyright (c) 2009 - 2011, Marat Zakiyanov aka Mario79, aka Mario
4
; All rights reserved.
5
;
6
; Redistribution and use in source and binary forms, with or without
7
; modification, are permitted provided that the following conditions are met:
8
;	 * Redistributions of source code must retain the above copyright
9
;	   notice, this list of conditions and the following disclaimer.
10
;	 * Redistributions in binary form must reproduce the above copyright
11
;	   notice, this list of conditions and the following disclaimer in the
12
;	   documentation and/or other materials provided with the distribution.
13
;	 * Neither the name of the  nor the
14
;	   names of its contributors may be used to endorse or promote products
15
;	   derived from this software without specific prior written permission.
16
;
17
; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
18
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
; DISCLAIMED. IN NO EVENT SHALL  BE LIABLE FOR ANY
21
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
;*****************************************************************************
28
; Rotate 32b, 24b, 16b, 8b
29
 
30
format MS COFF
31
 
32
public EXPORTS
33
 
34
section '.flat' code readable align 16
35
 
36
;include	'macros.inc'
37
include	'../../../../macros.inc'
38
;---------------------------------------------------------------------
39
START:
40
	pushad
41
	mov [pointer],eax
42
; ebx - direction
43
; 1 - clockwise, 2 - counter clockwise
44
; 3 - Left&Right, 4 - Up&Down
45
	mov [direction],ebx
46
	mov eax,[eax+4]
47
	mov [image_file],eax
48
 
49
    mov  esi,[eax+28]
50
    add  esi,eax
51
;	mov  ecx,[eax+32]
52
;	xor  ebx,ebx
53
;	mov  [raw_area],ebx
54
	mov ebx,[eax+12]
55
	cmp  ebx,32
56
	jne  @f
57
	mov  ebp,dword START.32
58
	jmp  .1
59
@@:
60
	cmp  ebx,24
61
	jne  @f
62
	mov  ebp,dword START.24
63
	jmp  .1
64
@@:
65
	cmp  ebx,16
66
	jne  @f
67
	mov  ebp,dword START.16
68
	jmp  .1
69
@@:
70
	cmp  ebx,15
71
	jne  @f
72
	inc  ebx
73
	mov  ebp,dword START.16
74
	jmp  .1
75
@@:
76
	cmp  ebx,8
77
	jne  @f
78
	mov  ebp,dword START.8
79
@@:
80
.1:
81
	shr  ebx,3
82
	mov  [bytes_to_pixel],ebx
83
	mov  ebx,[eax+4]
84
	imul ebx,[bytes_to_pixel]
85
	mov  [size_x],ebx
86
	mov  ebx,[eax+8]
87
	imul ebx,[bytes_to_pixel]
88
	mov  [size_y],ebx
89
 
90
	call .get_memory
91
 
92
	cmp  [direction],1
93
	jne  @f
94
	call .clockwise
95
	jmp .end
96
@@:
97
	cmp  [direction],2
98
	jne  @f
99
	call .counter_clockwise
100
	jmp .end
101
@@:
102
	cmp  [direction],3
103
	jne  @f
104
	call .Left_Right
105
	jmp .end
106
@@:
107
	cmp  [direction],4
108
	jne  .exit
109
	call .Up_Down
110
.end:
111
	xchg esi,edi
112
	mov ecx,[image_file]
113
	mov eax,[ecx+4]
114
	imul eax,[bytes_to_pixel]
115
	imul eax,[ecx+8]
116
 
117
	mov ecx,eax
118
	cld
119
	rep movsb
120
 
121
	mov   ecx,[raw_area]
122
	mcall 68,13
123
;---------------------------------------------------------------------
124
.ret_ok:
125
	cmp  [direction],1
126
	jne  @f
127
	call  .XY_data_exchange
128
	jmp  .exit
129
@@:
130
	cmp  [direction],2
131
	jne  .exit
132
	call  .XY_data_exchange
133
.exit:
134
	popad
135
	ret
136
;---------------------------------------------------------------------
137
.XY_data_exchange:
138
	mov ecx,[image_file]
139
	mov eax,[ecx+4]
140
	mov ebx,[ecx+8]
141
	mov [ecx+8],eax
142
	mov [ecx+4],ebx
143
	ret
144
;---------------------------------------------------------------------
145
.clockwise:
146
	push edi esi
147
 
148
	add  edi,[size_y]
149
	sub  edi,[bytes_to_pixel]
150
.y:
151
	push edi
152
	push ebx
153
.x:
154
	call ebp
155
	add  edi,[size_y]
156
	dec  ebx
157
	jnz  .x
158
 
159
	pop ebx
160
	pop  edi
161
 
162
	sub  edi,[bytes_to_pixel]
163
	dec ecx
164
	jnz .y
165
 
166
	pop esi edi
167
	ret
168
;---------------------------------------------------------------------
169
.counter_clockwise:
170
	push edi esi
171
 
172
	mov  eax,[eax+4]
173
	dec  eax
174
	imul eax,[size_y]
175
	add  edi,eax
176
.y1:
177
	push edi
178
	push ebx
179
.x1:
180
	call ebp
181
	sub  edi,[size_y]
182
	dec  ebx
183
	jnz  .x1
184
 
185
	pop  ebx
186
	pop  edi
187
 
188
	add  edi,[bytes_to_pixel]
189
	dec  ecx
190
	jnz .y1
191
 
192
	pop  esi edi
193
	ret
194
;---------------------------------------------------------------------
195
.Left_Right:
196
	push edi esi
197
	add  edi,[size_x]
198
.y2:
199
	push edi
200
	push ebx
201
.x2:
202
	sub  edi,[bytes_to_pixel]
203
	call ebp
204
	dec  ebx
205
	jnz  .x2
206
 
207
	pop  ebx
208
	pop  edi
209
 
210
	add  edi,[size_x]
211
	dec  ecx
212
	jnz .y2
213
 
214
	pop  esi edi
215
	ret
216
;---------------------------------------------------------------------
217
.Up_Down:
218
	push edi esi
219
 
220
	mov  eax,[eax+8]
221
	dec  eax
222
	imul eax,[size_x]
223
	add  edi,eax
224
.y3:
225
	push edi
226
	push ebx
227
.x3:
228
	call ebp
229
	add  edi,[bytes_to_pixel]
230
	dec  ebx
231
	jnz  .x3
232
 
233
	pop  ebx
234
	pop  edi
235
 
236
	sub  edi,[size_x]
237
	dec  ecx
238
	jnz .y3
239
 
240
	pop  esi edi
241
	ret
242
;---------------------------------------------------------------------
243
.32:
244
	cld
245
	lodsd
246
	mov  [edi],eax
247
 
248
	ret
249
;---------------------------------------------------------------------
250
.24:
251
	cld
252
	lodsw
253
	mov  [edi],ax
254
	lodsb
255
	mov  [edi+2],al
256
	ret
257
;---------------------------------------------------------------------
258
.16:
259
	cld
260
	lodsw
261
	mov  [edi],ax
262
	ret
263
;---------------------------------------------------------------------
264
.8:
265
	cld
266
	lodsb
267
	mov  [edi],al
268
	ret
269
;---------------------------------------------------------------------
270
.get_memory:
271
	mov  ecx,[eax+4]
272
	imul ecx,[eax+8]
273
	imul ecx,[bytes_to_pixel]
274
	push eax
275
	mcall 68,12
276
	mov  [raw_area],eax
277
	mov  edi,eax
278
	pop  eax
279
	mov  ebx,[eax+4]
280
	mov  ecx,[eax+8]
281
	ret
282
;---------------------------------------------------------------------
283
align 16
284
EXPORTS:
285
	dd      szStart,	START
286
	dd      szVersion,	0x00010001
287
	dd      0
288
 
289
szStart		db 'START',0
290
szVersion	db 'version',0
291
 
292
pointer		dd 0
293
image_file	dd 0
294
direction	dd 0
295
size_x		dd 0
296
size_y		dd 0
297
bytes_to_pixel dd 0
298
;delta		dd 0
299
;resolution	dd 0
300
;compression	dd 0
301
raw_area	dd 0