| 1 | /* |
| 2 | This file is part of the CVD Library. |
| 3 | |
| 4 | Copyright (C) 2005 The Authors |
| 5 | |
| 6 | This library is free software, see LICENSE file for details |
| 7 | */ |
| 8 | #include <X11/keysym.h> |
| 9 | #include <cvd/gl_helpers.h> |
| 10 | #include <cvd/image_io.h> |
| 11 | #include <cvd/videodisplay.h> |
| 12 | #include <iostream> |
| 13 | |
| 14 | using namespace CVD; |
| 15 | using namespace std; |
| 16 | |
| 17 | int main(int argc, char** argv) |
| 18 | { |
| 19 | if(argc != 1) |
| 20 | { |
| 21 | cerr << "Error: incorrect arguments\n."; |
| 22 | cerr << "usage: " << argv[0] << " < image\n"; |
| 23 | return 1; |
| 24 | } |
| 25 | |
| 26 | Image<Rgb<CVD::byte>> im; |
| 27 | |
| 28 | try |
| 29 | { |
| 30 | img_load(im, cin); |
| 31 | |
| 32 | VideoDisplay d(0, 0, im.size().x, im.size().y); |
| 33 | |
| 34 | d.select_events(KeyPressMask | ExposureMask); |
| 35 | |
| 36 | for(;;) |
| 37 | { |
| 38 | XEvent e; |
| 39 | |
| 40 | d.get_event(&e); |
| 41 | |
| 42 | if(e.type == KeyPress) |
| 43 | { |
| 44 | KeySym key; |
| 45 | XLookupString(&e.xkey, 0, 0, &key, 0); |
| 46 | |
| 47 | if(key == XK_Escape || key == XK_q) |
| 48 | break; |
| 49 | } |
| 50 | else if(e.type == Expose) |
| 51 | glDrawPixels(im); |
| 52 | } |
| 53 | } |
| 54 | catch(Exceptions::All b0rk) |
| 55 | { |
| 56 | cerr << "Error: " << b0rk.what() << endl; |
| 57 | return 1; |
| 58 | } |
| 59 | |
| 60 | return 0; |
| 61 | } |