qa_image_display.cpp

00001 
00002 /***************************************************************************
00003  *  qa_image_display.cpp - image display QA app
00004  *
00005  *  Created: Mon Nov 05 17:46:28 2007
00006  *  Copyright  2007  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 /// @cond QA
00025 
00026 #include <fvwidgets/image_display.h>
00027 #include <fvwidgets/sdl_keeper.h>
00028 #include <fvutils/readers/fvraw.h>
00029 
00030 #include <cstdio>
00031 #include <cstdlib>
00032 #include <unistd.h>
00033 
00034 #include <SDL.h>
00035 
00036 using namespace firevision;
00037 
00038 int
00039 main(int argc, char **argv)
00040 {
00041   const char *img_file;
00042   if ( argc > 1 ) {
00043     img_file = argv[1];
00044   } else {
00045     printf("Usage: %s <raw image file>\n", argv[0]);
00046     exit(-1);
00047   }
00048 
00049 
00050   FvRawReader *fvraw = new FvRawReader(img_file);
00051   unsigned char *buffer = malloc_buffer(fvraw->colorspace(),
00052                                         fvraw->pixel_width(), fvraw->pixel_height());
00053 
00054   fvraw->set_buffer(buffer);
00055   fvraw->read();
00056 
00057   ImageDisplay *display = new ImageDisplay(fvraw->pixel_width(), fvraw->pixel_height());
00058   display->show(fvraw->colorspace(), buffer);
00059 
00060   SDLKeeper::init(SDL_INIT_EVENTTHREAD);
00061 
00062   bool quit = false;
00063   while (! quit) {
00064     SDL_Event event;
00065     if ( SDL_WaitEvent(&event) ) {
00066       switch (event.type) {
00067       case SDL_QUIT:
00068         quit = true;
00069         break;
00070       default:
00071         break;
00072       }
00073     }
00074   }
00075 
00076   delete display;
00077   free(buffer);
00078   delete(fvraw);
00079 
00080   SDLKeeper::quit();
00081 
00082   return 0;
00083 }
00084 
00085 
00086 
00087 /// @endcond

Generated on 1 Mar 2011 for Fawkes API by  doxygen 1.6.1