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 int
00037 main(int argc, char **argv)
00038 {
00039   const char *img_file;
00040   if ( argc > 1 ) {
00041     img_file = argv[1];
00042   } else {
00043     printf("Usage: %s <raw image file>\n", argv[0]);
00044     exit(-1);
00045   }
00046
00047
00048   FvRawReader *fvraw = new FvRawReader(img_file);
00049   unsigned char *buffer = malloc_buffer(fvraw->colorspace(),
00050                                         fvraw->pixel_width(), fvraw->pixel_height());
00051
00052   fvraw->set_buffer(buffer);
00053   fvraw->read();
00054
00055   ImageDisplay *display = new ImageDisplay(fvraw->pixel_width(), fvraw->pixel_height());
00056   display->show(fvraw->colorspace(), buffer);
00057
00058   SDLKeeper::init(SDL_INIT_EVENTTHREAD);
00059
00060   bool quit = false;
00061   while (! quit) {
00062     SDL_Event event;
00063     if ( SDL_WaitEvent(&event) ) {
00064       switch (event.type) {
00065       case SDL_QUIT:
00066         quit = true;
00067         break;
00068       default:
00069         break;
00070       }
00071     }
00072   }
00073
00074   delete display;
00075   free(buffer);
00076   delete(fvraw);
00077
00078   SDLKeeper::quit();
00079
00080   return 0;
00081 }
00082
00083
00084 
00085 /// @endcond