Rev 2405 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
717 | mikedld | 1 | use32 |
2 | org 0x0 |
||
3 | |||
4 | db 'MENUET01' |
||
5 | dd 0x01, START, I_END, 0x1000, 0x1000, @PARAMS, 0x0 |
||
6 | |||
7 | ;----------------------------------------------------------------------------- |
||
8 | |||
9 | FALSE = 0 |
||
10 | TRUE = 1 |
||
11 | |||
12 | include '../../../../../proc32.inc' |
||
13 | include '../../../../../macros.inc' |
||
3014 | dunkaist | 14 | include '../../../../../dll.inc' |
717 | mikedld | 15 | |
16 | include '../../libio/libio.inc' |
||
783 | mikedld | 17 | include '../../libimg/libimg.inc' |
717 | mikedld | 18 | |
19 | ;----------------------------------------------------------------------------- |
||
20 | |||
21 | START: |
||
22 | mcall 68, 11 |
||
23 | |||
24 | stdcall dll.Load, @IMPORT |
||
25 | or eax, eax |
||
26 | jnz exit |
||
27 | |||
28 | invoke file.open, @PARAMS, O_READ |
||
29 | or eax, eax |
||
30 | jz exit |
||
31 | mov [fh], eax |
||
32 | invoke file.size, @PARAMS |
||
33 | mov [img_data_len], ebx |
||
34 | stdcall mem.Alloc, ebx |
||
35 | or eax, eax |
||
36 | jz exit |
||
37 | mov [img_data], eax |
||
38 | invoke file.read, [fh], eax, [img_data_len] |
||
39 | cmp eax, -1 |
||
40 | je exit |
||
41 | cmp eax, [img_data_len] |
||
42 | jne exit |
||
43 | invoke file.close, [fh] |
||
44 | inc eax |
||
45 | jz exit |
||
46 | |||
2405 | dunkaist | 47 | invoke img.decode, [img_data], [img_data_len], 0 |
717 | mikedld | 48 | or eax, eax |
49 | jz exit |
||
783 | mikedld | 50 | mov [image], eax |
717 | mikedld | 51 | ;----------------------------------------------------------------------------- |
52 | |||
2405 | dunkaist | 53 | redraw: |
717 | mikedld | 54 | call draw_window |
55 | |||
56 | still: |
||
57 | mcall 10 |
||
58 | cmp eax, 1 |
||
2405 | dunkaist | 59 | je redraw |
717 | mikedld | 60 | cmp eax, 2 |
61 | je key |
||
62 | cmp eax, 3 |
||
63 | je button |
||
64 | jmp still |
||
65 | |||
66 | key: |
||
67 | mcall 2 |
||
68 | jmp still |
||
69 | |||
70 | button: |
||
71 | mcall 17 |
||
783 | mikedld | 72 | shr eax, 8 |
73 | |||
74 | ; flip horizontally |
||
75 | cmp eax, 'flh' |
||
76 | jne @f |
||
77 | |||
78 | invoke img.flip, [image], FLIP_HORIZONTAL |
||
2405 | dunkaist | 79 | jmp redraw |
783 | mikedld | 80 | |
81 | ; flip vertically |
||
82 | @@: cmp eax, 'flv' |
||
83 | jne @f |
||
84 | |||
85 | invoke img.flip, [image], FLIP_VERTICAL |
||
2405 | dunkaist | 86 | jmp redraw |
783 | mikedld | 87 | |
88 | ; flip both horizontally and vertically |
||
89 | @@: cmp eax, 'flb' |
||
90 | jne @f |
||
91 | |||
92 | invoke img.flip, [image], FLIP_BOTH |
||
2405 | dunkaist | 93 | jmp redraw |
783 | mikedld | 94 | |
95 | ; rotate left |
||
96 | @@: cmp eax, 'rtl' |
||
97 | jne @f |
||
98 | |||
99 | invoke img.rotate, [image], ROTATE_90_CCW |
||
2405 | dunkaist | 100 | jmp redraw |
783 | mikedld | 101 | |
102 | ; rotate right |
||
103 | @@: cmp eax, 'rtr' |
||
104 | jne @f |
||
105 | |||
106 | invoke img.rotate, [image], ROTATE_90_CW |
||
2405 | dunkaist | 107 | jmp redraw |
783 | mikedld | 108 | |
109 | @@: cmp eax, 1 |
||
717 | mikedld | 110 | jne still |
111 | |||
112 | exit: |
||
113 | mcall -1 |
||
114 | |||
783 | mikedld | 115 | |
717 | mikedld | 116 | draw_window: |
117 | invoke gfx.open, TRUE |
||
118 | mov [ctx], eax |
||
119 | |||
783 | mikedld | 120 | mcall 0, <100, 640>, <100, 480>, 0x33FFFFFF, , s_header |
717 | mikedld | 121 | |
783 | mikedld | 122 | invoke gfx.pen.color, [ctx], 0x007F7F7F |
123 | invoke gfx.line, [ctx], 0, 30, 630, 30 |
||
124 | |||
125 | mcall 8, <5 + 25 * 0, 20>, <5, 20>, 'flh', 0x007F7F7F |
||
126 | mcall 8, <5 + 25 * 1, 20>, <5, 20>, 'flv', 0x007F7F7F |
||
127 | mcall 8, <5 + 25 * 2, 20>, <5, 20>, 'flb', 0x007F7F7F |
||
128 | |||
129 | invoke gfx.line, [ctx], 5 + 25 * 3, 0, 5 + 25 * 3, 30 |
||
130 | |||
131 | mcall 8, <10 + 25 * 3, 20>, <5, 20>, 'rtl', 0x007F7F7F |
||
132 | mcall 8, <10 + 25 * 4, 20>, <5, 20>, 'rtr', 0x007F7F7F |
||
133 | |||
2405 | dunkaist | 134 | mov eax, [image] |
135 | stdcall [img.draw], eax, 5, 35, [eax + Image.Width], [eax + Image.Height], 0, 0 |
||
717 | mikedld | 136 | |
137 | invoke gfx.close, [ctx] |
||
138 | ret |
||
139 | |||
140 | ;----------------------------------------------------------------------------- |
||
141 | |||
142 | s_header db 'Image Viewer (test app)', 0 |
||
143 | |||
144 | ;----------------------------------------------------------------------------- |
||
145 | |||
146 | align 16 |
||
147 | @IMPORT: |
||
148 | |||
149 | library \ |
||
150 | libio , 'libio.obj' , \ |
||
151 | libgfx , 'libgfx.obj' , \ |
||
152 | libimg , 'libimg.obj' |
||
153 | |||
154 | import libio , \ |
||
783 | mikedld | 155 | libio.init , 'lib_init' , \ |
2405 | dunkaist | 156 | file.size , 'file_size' , \ |
157 | file.open , 'file_open' , \ |
||
158 | file.read , 'file_read' , \ |
||
159 | file.close , 'file_close' |
||
717 | mikedld | 160 | |
783 | mikedld | 161 | import libgfx , \ |
162 | libgfx.init , 'lib_init' , \ |
||
2405 | dunkaist | 163 | gfx.open , 'gfx_open' , \ |
164 | gfx.close , 'gfx_close' , \ |
||
165 | gfx.pen.color , 'gfx_pen_color' , \ |
||
166 | gfx.line , 'gfx_line' |
||
717 | mikedld | 167 | |
783 | mikedld | 168 | import libimg , \ |
169 | libimg.init , 'lib_init' , \ |
||
2405 | dunkaist | 170 | img.draw , 'img_draw' , \ |
171 | img.decode , 'img_decode' , \ |
||
172 | img.flip , 'img_flip' , \ |
||
173 | img.rotate , 'img_rotate' |
||
717 | mikedld | 174 | |
175 | ;----------------------------------------------------------------------------- |
||
176 | |||
177 | I_END: |
||
178 | |||
179 | img_data dd ? |
||
180 | img_data_len dd ? |
||
181 | fh dd ? |
||
783 | mikedld | 182 | image dd ? |
717 | mikedld | 183 | |
184 | ctx dd ? |
||
185 | |||
186 | @PARAMS rb 5125,>10>5,>10>5,>5>5,>5>5,>5>100,>100,> |