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
35using namespace firevision;
36
37int
38main(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
75 SDLKeeper::quit();
76
77 return 0;
78}
79
80/// @endcond
FvRaw image reader implementation.
Definition: fvraw.h:35
virtual void read()
Read data from file.
Definition: fvraw.cpp:111
virtual unsigned int pixel_width()
Get width of read image in pixels.
Definition: fvraw.cpp:91
virtual colorspace_t colorspace()
Get colorspace from the just read image.
Definition: fvraw.cpp:81
virtual void set_buffer(unsigned char *yuv422planar_buffer)
Set buffer that the read image should be written to.
Definition: fvraw.cpp:75
virtual unsigned int pixel_height()
Get height of read image in pixels.
Definition: fvraw.cpp:101
Simple image display.
Definition: image_display.h:36