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 <fvwidgets/image_display.h>
27 #include <fvwidgets/sdl_keeper.h>
28 #include <fvutils/readers/fvraw.h>
29 
30 #include <cstdio>
31 #include <cstdlib>
32 #include <unistd.h>
33 
34 #include <SDL.h>
35 
36 using namespace firevision;
37 
38 int
39 main(int argc, char **argv)
40 {
41  const char *img_file;
42  if ( argc > 1 ) {
43  img_file = argv[1];
44  } else {
45  printf("Usage: %s <raw image file>\n", argv[0]);
46  exit(-1);
47  }
48 
49 
50  FvRawReader *fvraw = new FvRawReader(img_file);
51  unsigned char *buffer = malloc_buffer(fvraw->colorspace(),
52  fvraw->pixel_width(), fvraw->pixel_height());
53 
54  fvraw->set_buffer(buffer);
55  fvraw->read();
56 
57  ImageDisplay *display = new ImageDisplay(fvraw->pixel_width(), fvraw->pixel_height());
58  display->show(fvraw->colorspace(), buffer);
59 
60  SDLKeeper::init(SDL_INIT_EVENTTHREAD);
61 
62  bool quit = false;
63  while (! quit) {
64  SDL_Event event;
65  if ( SDL_WaitEvent(&event) ) {
66  switch (event.type) {
67  case SDL_QUIT:
68  quit = true;
69  break;
70  default:
71  break;
72  }
73  }
74  }
75 
76  delete display;
77  free(buffer);
78  delete(fvraw);
79 
81 
82  return 0;
83 }
84 
85 
86 
87 /// @endcond
static void init(unsigned int flags)
Init SDL.
Definition: sdl_keeper.cpp:64
Simple image display.
Definition: image_display.h:38
virtual void set_buffer(unsigned char *yuv422planar_buffer)
Set buffer that the read image should be written to.
Definition: fvraw.cpp:81
virtual void read()
Read data from file.
Definition: fvraw.cpp:121
static void quit()
Conditionally quit SDL.
Definition: sdl_keeper.cpp:92
virtual unsigned int pixel_width()
Get width of read image in pixels.
Definition: fvraw.cpp:99
virtual colorspace_t colorspace()
Get colorspace from the just read image.
Definition: fvraw.cpp:88
virtual unsigned int pixel_height()
Get height of read image in pixels.
Definition: fvraw.cpp:110
FvRaw image reader implementation.
Definition: fvraw.h:37
void show(colorspace_t colorspace, unsigned char *buffer)
Show image from given colorspace.