Cleanup in elf.c with .bss section clean; adm command mounts cdrom instead of floppy...
[ZeXOS.git] / apps / imgshow / main.c
blobeb81e1063e93955b3befef8383eccbae9e4151ca
1 /*
2 * ZeX/OS
3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <stdio.h>
21 #include <string.h>
22 #include <stdlib.h>
23 #include <libx/base.h>
24 #include <libx/object.h>
25 #include <libx/image.h>
26 #include <libx/cursor.h>
27 #include <libx/text.h>
29 #define ESC 1
30 #define ARROWLEFT 75
31 #define ARROWRIGHT 77
32 #define ARROWUP 72
33 #define ARROWDOWN 80
36 unsigned key_pressed (int keycode)
38 int scancode = getkey ();
40 if (scancode == keycode)
41 return 1;
43 if (scancode == keycode+128)
44 return 2;
45 else
46 return 0;
49 int main (int argc, char **argv)
51 if (argc < 1) {
52 puts ("Pls specify bmp image filename\nimgshow <bmpimage>\n");
53 exit (0);
56 /* Try open image */
57 xbitmap *image = ximage_open (argv[1]);
59 if (!image)
60 return 0;
62 /* Switch to VGA graphics mode */
63 xinit ();
65 /* Clean screen */
66 xcls (0);
68 /* Draw image to vga buffer */
69 ximage_draw (image, 0, 0, -1);
71 xtext_puts (10, image->width+10, 30, (char *) argv[1]);
73 char buf_x[4];
74 itoa (image->height, buf_x, 10);
76 char buf_y[4];
77 itoa (image->width, buf_y, 10);
79 xtext_puts (10, image->width+20, 30, "X: ");
80 xtext_puts (25, image->width+20, 30, buf_x);
82 xtext_puts (10, image->width+29, 30, "Y: ");
83 xtext_puts (25, image->width+29, 30, buf_y);
85 /* Flip double buffer - show image */
86 xfbswap ();
88 /* Repeat until escape is pressed */
89 while (!key_pressed (ESC))
90 schedule ();
92 /* Go back to textual mode */
93 xexit ();
95 /* Exit app */
96 return 0;