Fawkes API  Fawkes Development Version
qa_image_display.cpp
1 
2 /***************************************************************************
3  * qa_image_display.cpp - image display QA app
4  *
5  * Created: Mon Nov 05 17:46:28 2007
6  * Copyright 2007 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 /// @cond QA
25 
26 #include <fvutils/readers/fvraw.h>
27 #include <fvwidgets/image_display.h>
28 #include <fvwidgets/sdl_keeper.h>
29 
30 #include <SDL.h>
31 #include <cstdio>
32 #include <cstdlib>
33 #include <unistd.h>
34 
35 using namespace firevision;
36 
37 int
38 main(int argc, char **argv)
39 {
40  const char *img_file;
41  if (argc > 1) {
42  img_file = argv[1];
43  } else {
44  printf("Usage: %s <raw image file>\n", argv[0]);
45  exit(-1);
46  }
47 
48  FvRawReader * fvraw = new FvRawReader(img_file);
49  unsigned char *buffer =
50  malloc_buffer(fvraw->colorspace(), fvraw->pixel_width(), fvraw->pixel_height());
51 
52  fvraw->set_buffer(buffer);
53  fvraw->read();
54 
55  ImageDisplay *display = new ImageDisplay(fvraw->pixel_width(), fvraw->pixel_height());
56  display->show(fvraw->colorspace(), buffer);
57 
58  SDLKeeper::init(SDL_INIT_EVENTTHREAD);
59 
60  bool quit = false;
61  while (!quit) {
62  SDL_Event event;
63  if (SDL_WaitEvent(&event)) {
64  switch (event.type) {
65  case SDL_QUIT: quit = true; break;
66  default: break;
67  }
68  }
69  }
70 
71  delete display;
72  free(buffer);
73  delete (fvraw);
74 
76 
77  return 0;
78 }
79 
80 /// @endcond
firevision::SDLKeeper::init
static void init(unsigned int flags)
Init SDL.
Definition: sdl_keeper.cpp:57
firevision::ImageDisplay
Definition: image_display.h:34
firevision::FvRawReader
Definition: fvraw.h:38
firevision::SDLKeeper::quit
static void quit()
Conditionally quit SDL.
Definition: sdl_keeper.cpp:84
firevision::FvRawReader::set_buffer
virtual void set_buffer(unsigned char *yuv422planar_buffer)
Definition: fvraw.cpp:74
firevision::FvRawReader::pixel_width
virtual unsigned int pixel_width()
Definition: fvraw.cpp:90
firevision::FvRawReader::colorspace
virtual colorspace_t colorspace()
Definition: fvraw.cpp:80
firevision::FvRawReader::read
virtual void read()
Definition: fvraw.cpp:110
firevision::FvRawReader::pixel_height
virtual unsigned int pixel_height()
Definition: fvraw.cpp:100